http://codeforces.com/contest/1107/problem/D
You are given a binary matrix AA of size n×nn×n . Let's denote an xx -compression of the given matrix as a matrix BB of size nx×nxnx×nx such that for every i∈[1,n],j∈[1,n]i∈[1,n],j∈[1,n] the condition A[i][j]=B[⌈ix⌉][⌈jx⌉]A[i][j]=B[⌈ix⌉][⌈jx⌉] is met.
Obviously, xx -compression is possible only if xx divides nn , but this condition is not enough. For example, the following matrix of size 2×22×2 does not have any 22 -compression:
0101
1010
For the given matrix AA , find maximum xx such that an xx -compression of this matrix is possible.
Note that the input is given in compressed form. But even though it is compressed, you'd better use fast input.
Input
The first line contains one number nn (4≤n≤52004≤n≤5200 ) — the number of rows and columns in the matrix AA . It is guaranteed that nn is