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

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

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

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

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

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

f.s = c
c.t = m
c.v = f
m.t = c
m.v = f
assert f.s.v.s.txt == "c"