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

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

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

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

i.p = j
l.t = i
l.y = e
f.t = j
j.t = f
n.t = e
n.y = i
e.p = f
b.t = e
b.y = e
assert j.t.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

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

i.p = j
l.t = i
l.y = e
f.t = j
j.t = f
n.t = e
n.y = i
e.p = f
b.t = e
b.y = e
assert j.t.t.t.t.t.t.txt == "j"