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

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

k = A("k")
n = B("n")
i = A("i")

k.x = n
k.t = n
n.t = i
i.x = n
i.t = n
assert k.x.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.t: B = None
        self.txt = txt

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

k = A("k")
n = B("n")
i = A("i")

k.x = n
k.t = n
n.t = i
i.x = n
i.t = n
assert k.x.t.t.txt == "n"