easy
Complexity\n- Time complexity: O(n*m)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space complexity here, e.g. O(n) \n\n# 
# Complexity\n- Time complexity: $$O(n*m)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    bool areSimilar(vector<vector<int>>& M, int k) {\n        int n = M.size(), m = M[0].size();\n        k %= m;\n        for(int i=0; i<n; ++i){\n            for(int j=0; j<m; ++j){\n                int id = (i&1 == 0) ? (j-k+m)%m : (j+k)%m;\n                if(M[i][j] != M[i][id]) return false;\n            }\n        }\n        return true;\n    }\n};\n```
['Math', 'Matrix', 'C++']