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

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

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

l = A("l")
h = B("h")
i = C("i")
j = B("j")
d = C("d")
g = B("g")
k = B("k")
c = B("c")
b = C("b")

l.z = h
h.z = d
h.p = b
i.z = h
j.z = d
j.p = b
d.z = k
g.z = d
g.p = i
k.z = b
k.p = d
c.z = i
c.p = d
b.z = k
assert k.z.z.z.z.z.z.z.z.p.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

l = A("l")
h = B("h")
i = C("i")
j = B("j")
d = C("d")
g = B("g")
k = B("k")
c = B("c")
b = C("b")

l.z = h
h.z = d
h.p = b
i.z = h
j.z = d
j.p = b
d.z = k
g.z = d
g.p = i
k.z = b
k.p = d
c.z = i
c.p = d
b.z = k
assert k.z.z.z.z.z.z.z.z.p.txt == "d"