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

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

n = A("n")
m = B("m")
i = A("i")
l = A("l")
a = B("a")
d = B("d")

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

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

n = A("n")
m = B("m")
i = A("i")
l = A("l")
a = B("a")
d = B("d")

n.o = a
m.y = l
i.o = d
l.o = m
a.y = i
d.y = l
assert l.o.y.o.y.o.y.txt == "l"