The key point is to caculate the shifted indices of each element
\nclass Solution:\n    def areSimilar(self, mat: List[List[int]], k: int) -> bool:\n        """\n        The key point is to caculate the shifted indices of eac
```\nclass Solution:\n    def areSimilar(self, mat: List[List[int]], k: int) -> bool:\n        """\n        The key point is to caculate the shifted indices of each element\n        """\n        n = len(mat[0])\n        \n        for i,row in enumerate(mat): \n            # Left shift is index minuses k, otherwise right shift index adds k\n            if i % 2 != 0:\n                k = -k\n            for j in range(n):\n                # Caculate the shifted index\n                shifted = (j+k) % n\n                if row[j] != row[shifted]:\n                    return False\n                \n        return True\n```
['Python3']