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

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

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

h = A("h")
a = B("a")
m = C("m")
f = A("f")
k = A("k")
l = B("l")

h.y = m
h.p = k
a.v = h
m.z = a
f.y = m
f.p = k
k.y = m
k.p = f
l.v = k
assert f.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.p: A = None
        self.txt = txt

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

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

h = A("h")
a = B("a")
m = C("m")
f = A("f")
k = A("k")
l = B("l")

h.y = m
h.p = k
a.v = h
m.z = a
f.y = m
f.p = k
k.y = m
k.p = f
l.v = k
assert f.p.p.p.p.txt == "f"