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

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

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

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

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

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

k.v = g
c.t = g
c.r = k
g.t = c
g.r = k
assert g.r.v.t.txt == "c"