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

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

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

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

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

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

m.o = h
m.y = a
m.z = e
c.u = a
a.t = m
a.z = m
h.q = m
e.z = c
d.u = a
assert m.z.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.y: C = None
        self.z: E = None
        self.txt = txt

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

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

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

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

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

m.o = h
m.y = a
m.z = e
c.u = a
a.t = m
a.z = m
h.q = m
e.z = c
d.u = a
assert m.z.z.u.txt == "a"