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

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

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

f = A("f")
a = B("a")
e = C("e")
c = A("c")
k = C("k")
b = B("b")
m = C("m")
j = A("j")

f.p = j
a.t = j
e.o = f
c.p = j
k.o = j
b.t = c
m.o = j
j.p = c
assert c.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.t: A = None
        self.txt = txt

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

f = A("f")
a = B("a")
e = C("e")
c = A("c")
k = C("k")
b = B("b")
m = C("m")
j = A("j")

f.p = j
a.t = j
e.o = f
c.p = j
k.o = j
b.t = c
m.o = j
j.p = c
assert c.p.p.p.txt == "j"