You are given a grid A that consists of N rows and M columns. Each number in the grid is either 0 or 1.
Calculate the number of such triples (i,j,h) where for all the pairs (x,y), both x and y belong to [1,h] if y>=x and A[i+x−1][j+y−1] equals to 1. Of course, the square (i,j,i+h−1,j+h−1) should be inside of this grid. In other words, calculate the count of square submatrices of the given grid A which have their value equal to 1 for every element present on and above their main diagonal.
Input format
Output format
For each test case, print the count of square submatrices in a new line.
Constraints
1≤T≤101≤N,M≤3000
For the first testcase, there are total 6 submatrices which satisfy the given conditions. These triples (i,j,h) are (1,2,1),(1,2,2),(1,3,1),(2,1,1),(2,2,1) & (2,3,1).
For the second testcase, there are 5 such submatrices.
For the third testcase, there are no such submatrices possible.