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

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

l = A("l")
f = B("f")
e = A("e")
n = B("n")
m = B("m")
a = A("a")
b = B("b")
c = B("c")
k = A("k")
d = B("d")

l.z = e
f.y = d
f.p = n
e.z = k
n.y = d
n.p = b
m.y = b
m.p = b
a.z = k
b.y = c
b.p = c
c.y = m
c.p = d
k.z = e
d.y = b
d.p = b
assert e.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

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

l = A("l")
f = B("f")
e = A("e")
n = B("n")
m = B("m")
a = A("a")
b = B("b")
c = B("c")
k = A("k")
d = B("d")

l.z = e
f.y = d
f.p = n
e.z = k
n.y = d
n.p = b
m.y = b
m.p = b
a.z = k
b.y = c
b.p = c
c.y = m
c.p = d
k.z = e
d.y = b
d.p = b
assert e.z.z.z.z.z.txt == "k"