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

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

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

d.o = l
c.z = d
l.z = d
assert d.o.z.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

d.o = l
c.z = d
l.z = d
assert d.o.z.o.txt == "l"