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

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

d = A("d")
e = B("e")
l = A("l")

d.r = l
d.u = l
e.z = l
l.r = d
l.u = d
assert l.r.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.u: A = None
        self.txt = txt

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

d = A("d")
e = B("e")
l = A("l")

d.r = l
d.u = l
e.z = l
l.r = d
l.u = d
assert l.r.r.u.txt == "d"