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

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

f = A("f")
i = B("i")
e = B("e")
c = A("c")

f.x = c
i.y = e
e.y = i
c.x = f
assert f.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

f = A("f")
i = B("i")
e = B("e")
c = A("c")

f.x = c
i.y = e
e.y = i
c.x = f
assert f.x.x.x.x.txt == "f"