class A:
    def __init__(self, txt: str):
        self.s: B = 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.t: C = None
        self.txt = txt

g = A("g")
c = B("c")
a = C("a")
j = C("j")
i = B("i")
l = C("l")
n = C("n")
d = C("d")
m = C("m")
e = B("e")

g.s = i
c.t = g
a.t = j
j.t = m
i.t = g
l.t = m
n.t = a
d.t = m
m.t = l
e.t = g
assert l.t.t.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = 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.t: C = None
        self.txt = txt

g = A("g")
c = B("c")
a = C("a")
j = C("j")
i = B("i")
l = C("l")
n = C("n")
d = C("d")
m = C("m")
e = B("e")

g.s = i
c.t = g
a.t = j
j.t = m
i.t = g
l.t = m
n.t = a
d.t = m
m.t = l
e.t = g
assert l.t.t.t.t.t.t.t.txt == "m"