You are given a grid with m rows and n columns. Some cells hold a box. If every box moves down until it can move no further, the boxes end up stacked on the floor. Boxes cannot pass through each other, so a column holding k boxes ends up with its bottom k cells filled.
The distance a box moves is the number of cells it travels down from its starting cell to its final cell. The 5 by 4 grid in the first example holds 7 boxes, and the topmost box of the leftmost column moves down 2 cells. The 7 boxes in that grid move a total distance of 8.
Write a program that computes the total distance moved by all boxes, meaning the sum of the distances moved by each box.
The first line has the number of test cases T.
The first line of each test case has m and n (1≤m,n≤100). The next m lines each have n integers describing one row of the grid, given from the first row to the last row. A cell holding a box is 1 and an empty cell is 0, with one space between integers.
For each test case, print the total distance moved by all boxes on one line.