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

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

g = A("g")
k = B("k")
f = B("f")

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

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

g = A("g")
k = B("k")
f = B("f")

g.v = f
k.s = g
f.s = g
assert f.s.v.s.txt == "g"