You are given a matrix of integers with lines and columns, each indexed from .
A submatrix of matrix is a matrix which consists of all elements which come from the rows with indices and the columns with indices of matrix , where and are the edge rows and columns of the submatrix.
Task
Compute the numbers of submatrices of for which the greatest common divisor of their elements is (the greatest common divisor of a set of numbers is the greatest number which divides each of them without remainder).
Input data
The first line contains two integers integer and , the numbers of rows and columns of the matrix respectively.
The next lines each contain integers, where the element from the line of the input represents the matrix element (each dimension being indexed from ).
Output data
You need to write a single line with an integer: the numbers of submatrices of for which the greatest common divisor of their elements is .
Constraints and clarifications
# | Points | Constraints |
---|---|---|
1 | 10 | |
2 | 25 | |
3 | 25 | and |
4 | 25 | |
5 | 15 | No additional constraints. |
Example
stdin
2 2
1 2
3 4
stdout
5
Explanations
In the sample case, one example of a submatrix where the greatest common divisor of its elements is is the whole matrix.