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

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

class C:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

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

e = A("e")
d = B("d")
l = C("l")
h = D("h")
k = D("k")

e.o = d
e.z = l
e.r = h
e.q = h
d.z = l
l.p = k
h.u = d
h.z = e
k.u = d
k.z = e
assert h.z.o.z.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.z: C = None
        self.r: D = None
        self.q: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

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

e = A("e")
d = B("d")
l = C("l")
h = D("h")
k = D("k")

e.o = d
e.z = l
e.r = h
e.q = h
d.z = l
l.p = k
h.u = d
h.z = e
k.u = d
k.z = e
assert h.z.o.z.p.u.txt == "d"