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

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

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

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

class E:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

d = A("d")
k = B("k")
m = C("m")
e = D("e")
a = E("a")

d.u = k
d.z = e
k.p = d
m.v = e
m.w = d
m.o = k
e.t = k
a.z = e
assert m.w.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.z: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

d = A("d")
k = B("k")
m = C("m")
e = D("e")
a = E("a")

d.u = k
d.z = e
k.p = d
m.v = e
m.w = d
m.o = k
e.t = k
a.z = e
assert m.w.z.t.txt == "k"