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

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

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

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

b = A("b")
f = B("f")
j = C("j")
d = D("d")
i = A("i")

b.z = f
f.u = i
f.s = j
f.q = j
f.z = d
j.v = d
j.o = f
j.q = f
d.r = f
d.q = f
i.z = f
assert b.z.u.z.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

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

b = A("b")
f = B("f")
j = C("j")
d = D("d")
i = A("i")

b.z = f
f.u = i
f.s = j
f.q = j
f.z = d
j.v = d
j.o = f
j.q = f
d.r = f
d.q = f
i.z = f
assert b.z.u.z.q.q.txt == "f"