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

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

a = A("a")
k = B("k")
i = A("i")
b = B("b")

a.v = i
k.t = b
i.v = a
b.t = k
assert i.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

a = A("a")
k = B("k")
i = A("i")
b = B("b")

a.v = i
k.t = b
i.v = a
b.t = k
assert i.v.v.v.txt == "a"