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

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

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

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

class E:
    def __init__(self, txt: str):
        self.x: B = None
        self.w: C = None
        self.o: C = None
        self.p: D = None
        self.r: C = None
        self.txt = txt

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

f.q = e
e.w = d
a.u = b
a.y = e
m.q = e
d.x = e
d.w = b
d.o = c
d.r = c
d.p = m
c.u = a
c.y = e
b.u = a
b.y = e
assert m.q.w.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.x: B = None
        self.w: C = None
        self.o: C = None
        self.p: D = None
        self.r: C = None
        self.txt = txt

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

f.q = e
e.w = d
a.u = b
a.y = e
m.q = e
d.x = e
d.w = b
d.o = c
d.r = c
d.p = m
c.u = a
c.y = e
b.u = a
b.y = e
assert m.q.w.o.y.txt == "e"