python
Code

# Code
```python3 []
class Solution:
    def areSimilar(self, mat: List[List[int]], k: int) -> bool:
        n = len(mat[0])
        r = k % n
        if not r: return True
        g = gcd(n, k)
        q = n // g
        for row in mat:
            if len(set(row)) > 1:
                if row[:g] * q != row:
                    return False
        return True
```
['Python3']