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

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

n = A("n")
k = B("k")
e = A("e")
a = A("a")
c = B("c")
l = A("l")
b = B("b")
m = B("m")
g = A("g")

n.o = e
k.r = g
e.o = l
a.o = e
c.r = n
l.o = n
b.r = g
m.r = e
g.o = l
assert a.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.r: A = None
        self.txt = txt

n = A("n")
k = B("k")
e = A("e")
a = A("a")
c = B("c")
l = A("l")
b = B("b")
m = B("m")
g = A("g")

n.o = e
k.r = g
e.o = l
a.o = e
c.r = n
l.o = n
b.r = g
m.r = e
g.o = l
assert a.o.o.o.o.o.o.txt == "n"