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

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

f = A("f")
b = B("b")
k = B("k")
i = A("i")

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

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

f = A("f")
b = B("b")
k = B("k")
i = A("i")

f.v = b
f.o = i
b.x = i
b.s = i
k.x = f
k.s = f
i.v = b
i.o = f
assert f.v.x.v.s.txt == "i"