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

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

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

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

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

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

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

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

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

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

k.p = a
i.t = k
i.z = k
g.z = b
b.w = g
l.w = g
c.z = b
a.p = h
n.p = k
d.t = k
d.z = a
h.p = a
assert k.p.p.p.p.p.p.p.p.p.p.txt == "h"