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

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

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

l = A("l")
b = B("b")
f = C("f")
j = C("j")
n = A("n")
h = A("h")
c = B("c")
i = B("i")

l.p = h
b.u = j
f.r = n
j.r = n
n.p = l
h.p = n
c.u = j
i.u = f
assert l.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: C = None
        self.txt = txt

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

l = A("l")
b = B("b")
f = C("f")
j = C("j")
n = A("n")
h = A("h")
c = B("c")
i = B("i")

l.p = h
b.u = j
f.r = n
j.r = n
n.p = l
h.p = n
c.u = j
i.u = f
assert l.p.p.p.p.p.p.p.txt == "h"