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

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

m = A("m")
n = B("n")
c = B("c")
b = A("b")
a = B("a")
l = A("l")
d = A("d")

m.o = a
m.s = l
n.o = c
c.o = n
b.o = a
b.s = m
a.o = n
l.o = c
l.s = d
d.o = c
d.s = m
assert n.o.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.s: A = None
        self.txt = txt

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

m = A("m")
n = B("n")
c = B("c")
b = A("b")
a = B("a")
l = A("l")
d = A("d")

m.o = a
m.s = l
n.o = c
c.o = n
b.o = a
b.s = m
a.o = n
l.o = c
l.s = d
d.o = c
d.s = m
assert n.o.o.o.o.o.o.txt == "n"