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

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

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

j = A("j")
b = B("b")
f = C("f")
e = B("e")
g = B("g")
n = C("n")
h = C("h")
l = C("l")
m = A("m")

j.p = m
b.o = n
f.t = h
e.o = f
g.o = f
n.t = f
h.t = f
l.t = h
m.p = j
assert e.o.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

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

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

j = A("j")
b = B("b")
f = C("f")
e = B("e")
g = B("g")
n = C("n")
h = C("h")
l = C("l")
m = A("m")

j.p = m
b.o = n
f.t = h
e.o = f
g.o = f
n.t = f
h.t = f
l.t = h
m.p = j
assert e.o.t.t.t.t.t.txt == "h"