Greg has an m×n grid of lightbulbs that he wants to turn on. Initially, some of the bulbs are on and some are off. Greg can toggle bulbs by shooting his laser at them. When he shoots a bulb, that bulb switches between on and off. The shot also toggles every bulb below it in the same column and every bulb to its left in the same row.
Find the smallest number of shots Greg needs to turn all the bulbs on.
Input
The first line contains a single integer T (1≤T≤10), the number of test cases. Each test case starts with a line containing two space-separated integers m and n (1≤m,n≤400). Each of the next m lines is a string of length n made of 1s and 0s. A 1 is a bulb that is on, and a 0 is a bulb that is off.
Output
For each test case, print on its own line the minimum number of shots Greg needs to turn on all the bulbs.
Hint
In the first test case, one shot at the top right bulb turns on every bulb that is off and does not toggle any bulb that is on.
In the second test case, shooting the top left and top right bulbs is enough.