#C5806. Minimum Moves to Collect Coins

    ID: 49496 Type: Default 1000ms 256MiB

Minimum Moves to Collect Coins

Minimum Moves to Collect Coins

You are given a grid of size \(m \times n\) where each cell contains a non-negative integer representing the number of coins in that cell. In one move, you can collect all coins from a cell if the cell has at least one coin.

Your task is to determine the minimum number of moves required to collect all the coins in each grid. This is equivalent to counting the number of cells that contain a positive number.

You will be given \(T\) test cases. For each test case, compute and output the number of moves required.

inputFormat

The input begins with an integer \(T\), the number of test cases. For each test case, the first line contains two integers \(m\) and \(n\) representing the number of rows and columns in the grid respectively. The next \(m\) lines each contain \(n\) space-separated integers representing the coins in each cell of the grid.

outputFormat

For each test case, output a single integer on a new line which is the minimum number of moves required to collect all the coins from the grid.

## sample
1
2 3
0 0 0
0 0 0
0

</p>