class A:
    def __init__(self, txt: str):
        self.t: B = 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.u: A = None
        self.p: B = None
        self.txt = txt

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

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

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

j.t = m
m.z = e
e.u = j
e.p = m
h.y = e
b.x = h
a.y = e
f.u = j
f.p = m
c.u = j
c.p = m
assert j.t.z.p.z.p.z.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = 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.u: A = None
        self.p: B = None
        self.txt = txt

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

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

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

j.t = m
m.z = e
e.u = j
e.p = m
h.y = e
b.x = h
a.y = e
f.u = j
f.p = m
c.u = j
c.p = m
assert j.t.z.p.z.p.z.p.txt == "m"