C++ Solution
\n# Code\ncpp []\nclass Solution {\npublic:\n    bool areSimilar(vector<vector<int>>& mat, int k) {\n        int m = mat.size(), n = mat[0].size() , x = k % n;\
\n# Code\n```cpp []\nclass Solution {\npublic:\n    bool areSimilar(vector<vector<int>>& mat, int k) {\n        int m = mat.size(), n = mat[0].size() , x = k % n;\n        for(int i = 0; i < m; i++){\n            for(int j = 0; j < n; j++){\n                if( i % 2 == 0 && mat[i][(j + x) % n] != mat[i][j]) return false;\n                else if(((j - x) >= 0? mat[i][j - x] : mat[i][j - x + n]) != mat[i][j]) return false;;\n            }\n        } \n        return true;\n    }\n};\n```
['C++']