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

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

l = A("l")
n = B("n")
a = A("a")

l.s = n
l.r = n
n.u = l
a.s = n
a.r = n
assert l.r.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.r: B = None
        self.txt = txt

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

l = A("l")
n = B("n")
a = A("a")

l.s = n
l.r = n
n.u = l
a.s = n
a.r = n
assert l.r.u.r.txt == "n"