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

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

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

c.p = m
a.u = e
l.p = c
f.p = k
k.p = f
h.p = l
e.u = a
m.p = f
assert f.p.p.p.p.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.u: B = None
        self.txt = txt

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

c.p = m
a.u = e
l.p = c
f.p = k
k.p = f
h.p = l
e.u = a
m.p = f
assert f.p.p.p.p.p.p.p.p.txt == "f"