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

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

h = A("h")
e = B("e")
c = B("c")
n = B("n")
i = B("i")
m = A("m")
k = A("k")
b = B("b")
l = A("l")
j = B("j")

h.o = j
h.y = e
e.r = c
c.r = j
n.r = i
i.r = n
m.o = n
m.y = c
k.o = n
k.y = i
b.r = e
l.o = j
l.y = n
j.r = c
assert m.o.r.r.r.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.y: B = None
        self.txt = txt

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

h = A("h")
e = B("e")
c = B("c")
n = B("n")
i = B("i")
m = A("m")
k = A("k")
b = B("b")
l = A("l")
j = B("j")

h.o = j
h.y = e
e.r = c
c.r = j
n.r = i
i.r = n
m.o = n
m.y = c
k.o = n
k.y = i
b.r = e
l.o = j
l.y = n
j.r = c
assert m.o.r.r.r.r.r.r.r.r.txt == "n"