C++ - simple solution
\n# Code\n\nclass Solution {\npublic:\n    bool areSimilar(vector<vector<int>>& mat, int k) {\n        int r=mat.size(),n=mat[0].size();\n        k = k%n;\n    
\n# Code\n```\nclass Solution {\npublic:\n    bool areSimilar(vector<vector<int>>& mat, int k) {\n        int r=mat.size(),n=mat[0].size();\n        k = k%n;\n        for (int i=0;i<r;i++){\n            for (int j=0;j<n;j++){\n                if (i%2==0){\n                    //left shift\n                    if (mat[i][j]!=mat[i][(j-k+n)%n]) return false;\n                }\n                else{\n                    //right shift\n                    if (mat[i][j]!=mat[i][(j+k)%n]) return false;\n                    \n                }\n            }\n        }\n        return true;\n    }\n};\n```
['C++']