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

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

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

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

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

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

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

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

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