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

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

c = A("c")
f = B("f")
k = B("k")
n = A("n")
a = A("a")
m = B("m")
g = A("g")
e = B("e")
l = A("l")
j = A("j")

c.p = j
f.z = l
f.s = n
k.z = g
k.s = j
n.p = l
a.p = g
m.z = n
m.s = n
g.p = a
e.z = a
e.s = j
l.p = c
j.p = l
assert n.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.z: A = None
        self.s: A = None
        self.txt = txt

c = A("c")
f = B("f")
k = B("k")
n = A("n")
a = A("a")
m = B("m")
g = A("g")
e = B("e")
l = A("l")
j = A("j")

c.p = j
f.z = l
f.s = n
k.z = g
k.s = j
n.p = l
a.p = g
m.z = n
m.s = n
g.p = a
e.z = a
e.s = j
l.p = c
j.p = l
assert n.p.p.p.p.txt == "l"