class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.u: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: A = None
        self.z: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: A = None
        self.w: A = None
        self.x: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.q: B = None
        self.r: A = None
        self.o: B = None
        self.txt = txt

g = A("g")
c = B("c")
a = C("a")
f = D("f")

g.o = f
g.u = c
c.v = g
c.z = g
a.s = g
a.w = g
a.x = f
f.q = c
f.o = c
f.r = g
assert c.v.o.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.u: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: A = None
        self.z: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: A = None
        self.w: A = None
        self.x: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.q: B = None
        self.r: A = None
        self.o: B = None
        self.txt = txt

g = A("g")
c = B("c")
a = C("a")
f = D("f")

g.o = f
g.u = c
c.v = g
c.z = g
a.s = g
a.w = g
a.x = f
f.q = c
f.o = c
f.r = g
assert c.v.o.q.txt == "c"