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

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

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

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

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

k = A("k")
b = B("b")
n = C("n")
c = D("c")
d = E("d")
h = C("h")
l = D("l")
a = D("a")
i = E("i")

k.r = n
b.r = c
b.q = i
b.u = h
n.x = b
c.r = h
c.z = h
d.p = i
h.x = b
l.r = h
l.z = h
a.r = n
a.z = n
i.p = d
assert d.p.p.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

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

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

k = A("k")
b = B("b")
n = C("n")
c = D("c")
d = E("d")
h = C("h")
l = D("l")
a = D("a")
i = E("i")

k.r = n
b.r = c
b.q = i
b.u = h
n.x = b
c.r = h
c.z = h
d.p = i
h.x = b
l.r = h
l.z = h
a.r = n
a.z = n
i.p = d
assert d.p.p.p.p.p.p.p.txt == "i"