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

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

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

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

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

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

l.w = i
i.r = l
i.o = m
m.r = l
m.o = i
assert i.o.r.w.txt == "i"