Олимпиадный тренинг

Задача 38791. Submatrix - 1


Задача

Темы: Словари
Fili has an N×N square matrix A, but it seems too big for him. He likes  matrices of size k×k (k<N) much more.
Filya wants to get a matrix of the required size by taking some submatrix of the original matrix.
The submatrix k×k of the matrix A in this case, Filya considers the matrix B such that bi,j=ai+x,j+y, for all i, j from 1 to k. From this definition, you can see that the submatrix of the original matrix is ​​given by a pair of numbers (x, y).
In order to choose the most interesting submatrix for himself, Filya wants to know how many ways there are to choose from the original matrix two different (characterizing pairs (x, y) differ at least in one position) equal submatrices k×k. Two matrices Q and P of size k×k are considered equal if for any i,j:1≤i,j≤k qi,j=pi,j .
If the equality condition is not met, the matrices are considered unequal.

Input
The first line of the input file contains two natural numbers N and k - the sizes of the original and required matrix.
(1<=k<=N<=10). The next N lines contain space-separated N natural numbers ai,j - elements of the original matrix (1<=ai,j<10).

Imprint
In a single line of the output file print a single number - the number of ways to select from the original matrix two different equal submatrices of size k×k.
 
Examples
# Input Output
1 3 1
1 2 3
4 5 6
7 8 9
0
2 3 1
1 1 1
1 1 1
1 1 1
36
3 3 2
1 2 1
1 1 2
1 1 1
1