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

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

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

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

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

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

f.y = b
f.t = i
i.v = f
i.o = f
b.y = f
b.t = i
assert i.v.t.v.txt == "f"