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

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

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

m.s = l
j.o = l
l.o = j
assert m.s.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

m.s = l
j.o = l
l.o = j
assert m.s.o.o.txt == "l"