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

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

class C:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.s: E = None
        self.x: B = None
        self.p: A = None
        self.u: A = None
        self.z: E = None
        self.txt = txt

a = A("a")
b = B("b")
m = C("m")
f = D("f")
d = E("d")
h = B("h")
l = A("l")
n = E("n")

a.t = m
a.q = h
b.q = n
m.p = d
f.s = d
f.x = h
d.s = n
d.z = n
d.x = b
d.p = a
d.u = a
h.q = d
l.t = m
l.q = h
n.s = d
n.z = d
n.x = b
n.p = l
n.u = a
assert m.p.x.q.x.q.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.q: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.s: E = None
        self.x: B = None
        self.p: A = None
        self.u: A = None
        self.z: E = None
        self.txt = txt

a = A("a")
b = B("b")
m = C("m")
f = D("f")
d = E("d")
h = B("h")
l = A("l")
n = E("n")

a.t = m
a.q = h
b.q = n
m.p = d
f.s = d
f.x = h
d.s = n
d.z = n
d.x = b
d.p = a
d.u = a
h.q = d
l.t = m
l.q = h
n.s = d
n.z = d
n.x = b
n.p = l
n.u = a
assert m.p.x.q.x.q.x.q.txt == "n"