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

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

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

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

e = A("e")
k = B("k")
m = C("m")
h = D("h")

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

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

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

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

e = A("e")
k = B("k")
m = C("m")
h = D("h")

e.t = k
e.u = k
e.r = m
k.s = h
k.p = h
m.z = k
m.o = k
h.s = e
h.q = m
assert m.o.p.q.z.txt == "k"