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

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

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

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

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

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

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

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

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

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

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