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

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

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

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

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

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

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