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

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

b = A("b")
i = B("i")
l = B("l")

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

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

b = A("b")
i = B("i")
l = B("l")

b.z = l
i.o = b
i.p = l
l.o = b
l.p = i
assert b.z.o.z.txt == "l"