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

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

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

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

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

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

d.r = l
d.x = j
j.u = l
j.z = l
l.u = j
l.z = j
assert d.x.z.z.txt == "j"