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.z: B = None
        self.r: A = None
        self.txt = txt

j = A("j")
l = B("l")
a = C("a")
f = B("f")
c = B("c")
d = C("d")
h = A("h")

j.z = d
l.p = c
a.z = f
a.r = j
f.p = c
c.p = f
d.z = f
d.r = h
h.z = a
assert c.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.z: B = None
        self.r: A = None
        self.txt = txt

j = A("j")
l = B("l")
a = C("a")
f = B("f")
c = B("c")
d = C("d")
h = A("h")

j.z = d
l.p = c
a.z = f
a.r = j
f.p = c
c.p = f
d.z = f
d.r = h
h.z = a
assert c.p.p.p.p.p.p.p.txt == "f"