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

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

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

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

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

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

k.r = c
c.t = k
f.t = k
assert f.t.r.t.txt == "k"