In a matrix of integers M, m_{i,j} denotes the element of the matrix at i^{th} row and j^{th} column. A quadruple ⟨a, b, c, d⟩ of M is considered beautiful if and only if (a < b), (c < d), and m_{a,c} = m_{a,d} = m_{b,c} = m_{b,d} in matrix M.
Given a matrix of integers M, determine how many beautiful quadruple of M there are.
For example, consider the following matrix of 3 x 4:
There are two beautiful quadruples, i.e. ⟨1, 3, 2, 4⟩ and ⟨2, 3, 2, 3⟩, as shown in the following figures.
There are no other quadruples which are beautiful, thus, in this example, the output is 2.
The first line of input contains an integer T (T ≤ 100) denoting the number of cases. Each case begins with two integers R and C (2 ≤ R, C ≤ 150) denoting the size of the matrix (row and column respectively). The next R lines each contains C integers m_{i,j} (1 ≤ m_{i,j} ≤ 10^{9}) representing the matrix's element, respectively for i = 1..R and j = 1..C.
For each case, output in a line "Case #X: Y" where X is the case number, starts from 1, and Y is the output for that particular case.
