PHP. T - O(m*n), M - O(1).
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(m*n)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1)\n# Code\n```\nclass Solution {\n\n    /**\n     * @param Integer[][] $mat\n     * @param Integer $k\n     * @return Boolean\n     */\n    function areSimilar($mat, $k) {\n        \n        foreach($mat as $row){\n            $l = count($row);\n            $kk = $k % $l;            \n            for($i = 0; $i <= $kk;$i++){\n                $kkk = ($i + $kk) % $l;\n                if($row[$i] != $row[$kkk]) return false;\n            }\n        }\n        \n        return true;\n    }\n}\n```
['PHP']