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

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

l = A("l")
j = B("j")
n = B("n")
e = B("e")
b = A("b")

l.u = b
l.s = b
j.o = b
n.o = b
e.o = b
b.u = l
b.s = l
assert l.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.s: A = None
        self.txt = txt

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

l = A("l")
j = B("j")
n = B("n")
e = B("e")
b = A("b")

l.u = b
l.s = b
j.o = b
n.o = b
e.o = b
b.u = l
b.s = l
assert l.s.s.s.txt == "b"