check k and -k periodicity for the rows
\n\nfn f(x: & [i32], k: usize) -> bool {\n    let m = x.len();\n    (0..m).all(|i|x[i]==x[(i+k).rem_euclid(m)])\n}\n\nimpl Solution {\n    pub fn are_similar(ma
\n```\nfn f(x: & [i32], k: usize) -> bool {\n    let m = x.len();\n    (0..m).all(|i|x[i]==x[(i+k).rem_euclid(m)])\n}\n\nimpl Solution {\n    pub fn are_similar(mat: Vec<Vec<i32>>, k: i32) -> bool {\n        let n = mat.len();\n        let m = mat[0].len() as i32;\n        (0..n).step_by(2).all(|i|f(&mat[i], k.rem_euclid(m) as usize)) &&\n        (1..n).step_by(2).all(|i|f(&mat[i], (-k).rem_euclid(m) as usize))\n    }\n}\n```
['Rust']