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

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

b = A("b")
n = B("n")
h = B("h")
f = B("f")
g = B("g")
m = A("m")
k = A("k")
j = A("j")
e = A("e")

b.o = m
n.y = h
h.y = f
f.y = h
g.y = f
m.o = j
k.o = b
j.o = k
e.o = m
assert m.o.o.o.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

b = A("b")
n = B("n")
h = B("h")
f = B("f")
g = B("g")
m = A("m")
k = A("k")
j = A("j")
e = A("e")

b.o = m
n.y = h
h.y = f
f.y = h
g.y = f
m.o = j
k.o = b
j.o = k
e.o = m
assert m.o.o.o.o.o.o.o.o.txt == "m"