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.p: A = None
        self.txt = txt

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

k.x = a
k.t = a
a.p = n
n.x = a
n.t = a
assert k.t.p.x.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.p: A = None
        self.txt = txt

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

k.x = a
k.t = a
a.p = n
n.x = a
n.t = a
assert k.t.p.x.txt == "a"