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

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

l = A("l")
e = B("e")
b = B("b")
g = A("g")
m = B("m")
d = A("d")

l.o = g
e.u = d
b.u = l
g.o = l
m.u = l
d.o = l
assert l.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.u: A = None
        self.txt = txt

l = A("l")
e = B("e")
b = B("b")
g = A("g")
m = B("m")
d = A("d")

l.o = g
e.u = d
b.u = l
g.o = l
m.u = l
d.o = l
assert l.o.o.o.o.o.o.txt == "l"