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

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

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

b.s = i
b.x = i
a.o = i
i.s = b
i.x = b
assert b.s.s.x.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.x: A = None
        self.txt = txt

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

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

b.s = i
b.x = i
a.o = i
i.s = b
i.x = b
assert b.s.s.x.txt == "i"