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

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

a = A("a")
i = B("i")
d = B("d")

a.z = d
i.r = d
i.v = d
d.r = i
d.v = i
assert a.z.r.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

a = A("a")
i = B("i")
d = B("d")

a.z = d
i.r = d
i.v = d
d.r = i
d.v = i
assert a.z.r.v.txt == "d"