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

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

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

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

k.z = f
k.p = n
j.p = c
j.r = n
l.y = n
l.r = g
f.p = l
f.r = n
m.y = n
m.r = f
c.y = k
c.r = j
g.p = c
g.r = k
n.z = f
n.p = k
assert n.p.p.p.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.p: A = None
        self.txt = txt

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

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

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

k.z = f
k.p = n
j.p = c
j.r = n
l.y = n
l.r = g
f.p = l
f.r = n
m.y = n
m.r = f
c.y = k
c.r = j
g.p = c
g.r = k
n.z = f
n.p = k
assert n.p.p.p.p.p.p.p.p.txt == "n"