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

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

e = A("e")
c = B("c")
b = A("b")

e.x = c
c.v = b
b.x = c
assert c.v.x.v.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

e = A("e")
c = B("c")
b = A("b")

e.x = c
c.v = b
b.x = c
assert c.v.x.v.txt == "b"