Partial Sums

아직 제출이 없습니다시간 제한1초메모리 제한256 MB

문제

You have a matrix A_0A\_0, consisting of nn rows and mm columns. Rows and columns are numbered with consecutive natural numbers starting from 11. The elements of the matrix are zeros and ones. Denote the element of this matrix at the intersection of the ii row and jj column as A_0\[i,j]A\_0\[i, j].

Consider an infinite sequence of matrices A_kA\_k. The matrix A_kA\_k (k>0k > 0) also consists of nn rows and mm columns and it is a matrix of partial sums for the matrix A_k1A\_{k - 1} modulo 22. Formally, this means that A_k\[i,j]=_1ui_1vjA_k1\[u,v]mod2A\_k\[i, j] = \sum\_{1 \le u \le i} \sum\_{1 \le v \le j} A\_{k - 1}\[u, v] \mod 2

It is required to find a minimum k>0k > 0 such that the matrices A_kA\_k and A_0A\_0 are element-wise equal.

입력

The first line of the input data contains two integers nn and mm --- the number of rows and columns in the matrix A_0A\_0. The following nn lines contain descriptions of the rows of the matrix. Each line consists of mm characters, each character is either 00 or 11.

출력

Output the single number kk --- the answer to the problem.

제한

  • 1n,m1061 \le n, m \le 10^6
  • n×m106n \times m \le 10^6