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

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

m = A("m")
h = B("h")
i = B("i")
e = A("e")
l = B("l")
k = A("k")
f = A("f")
c = B("c")
g = B("g")
a = A("a")

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

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

m = A("m")
h = B("h")
i = B("i")
e = A("e")
l = B("l")
k = A("k")
f = A("f")
c = B("c")
g = B("g")
a = A("a")

m.y = a
m.t = e
h.o = c
i.o = h
e.y = a
e.t = m
l.o = i
k.y = f
k.t = m
f.y = e
f.t = e
c.o = g
g.o = l
a.y = e
a.t = e
assert g.o.o.o.o.o.o.txt == "l"