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

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

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

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

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

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

n.s = a
k.z = n
k.t = n
a.z = n
a.t = n
assert k.t.s.t.txt == "n"