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

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

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

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

g.t = l
m.y = n
m.r = g
n.u = j
j.y = n
j.r = l
l.t = a
b.y = n
b.r = l
d.y = n
d.r = g
c.t = g
a.t = c
assert l.t.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.y: C = None
        self.r: A = None
        self.txt = txt

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

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

g.t = l
m.y = n
m.r = g
n.u = j
j.y = n
j.r = l
l.t = a
b.y = n
b.r = l
d.y = n
d.r = g
c.t = g
a.t = c
assert l.t.t.t.t.t.t.txt == "c"