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

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

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

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

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

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

a.v = l
i.o = l
l.o = i
assert i.o.o.o.txt == "l"