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

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

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

f.u = c
i.v = f
c.v = f
assert i.v.u.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

f.u = c
i.v = f
c.v = f
assert i.v.u.v.txt == "f"