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

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

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

d = A("d")
b = B("b")
g = C("g")
h = B("h")
m = C("m")
i = B("i")
l = A("l")
a = A("a")
k = A("k")
e = C("e")

d.t = k
d.y = l
d.r = a
b.o = h
b.s = d
b.t = i
g.t = m
h.o = b
h.t = b
h.s = a
m.t = g
i.o = b
i.t = b
i.s = a
l.t = d
l.r = d
l.y = k
a.t = k
a.y = l
a.r = d
k.t = d
k.y = d
k.r = l
e.t = m
assert m.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.y: A = None
        self.r: A = None
        self.txt = txt

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

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

d = A("d")
b = B("b")
g = C("g")
h = B("h")
m = C("m")
i = B("i")
l = A("l")
a = A("a")
k = A("k")
e = C("e")

d.t = k
d.y = l
d.r = a
b.o = h
b.s = d
b.t = i
g.t = m
h.o = b
h.t = b
h.s = a
m.t = g
i.o = b
i.t = b
i.s = a
l.t = d
l.r = d
l.y = k
a.t = k
a.y = l
a.r = d
k.t = d
k.y = d
k.r = l
e.t = m
assert m.t.t.t.t.t.txt == "g"