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

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

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

m = A("m")
b = B("b")
i = C("i")
n = C("n")
j = B("j")
f = C("f")
c = B("c")
e = A("e")

m.z = n
b.p = c
i.r = j
n.r = j
j.p = b
f.r = j
c.p = j
e.z = f
assert c.p.p.p.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

m = A("m")
b = B("b")
i = C("i")
n = C("n")
j = B("j")
f = C("f")
c = B("c")
e = A("e")

m.z = n
b.p = c
i.r = j
n.r = j
j.p = b
f.r = j
c.p = j
e.z = f
assert c.p.p.p.p.p.p.p.p.txt == "b"