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

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

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

class D:
    def __init__(self, txt: str):
        self.v: C = None
        self.r: A = None
        self.txt = txt

f = A("f")
d = B("d")
j = C("j")
c = D("c")
e = A("e")
a = A("a")

f.q = j
f.z = j
f.v = a
d.x = f
d.q = c
j.z = d
j.o = d
j.t = e
j.u = c
c.v = j
c.r = f
e.q = j
e.z = j
e.v = a
a.q = j
a.z = j
a.v = f
assert e.v.v.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.v: A = None
        self.z: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.v: C = None
        self.r: A = None
        self.txt = txt

f = A("f")
d = B("d")
j = C("j")
c = D("c")
e = A("e")
a = A("a")

f.q = j
f.z = j
f.v = a
d.x = f
d.q = c
j.z = d
j.o = d
j.t = e
j.u = c
c.v = j
c.r = f
e.q = j
e.z = j
e.v = a
a.q = j
a.z = j
a.v = f
assert e.v.v.v.q.txt == "j"