Rayan found an N×M grid of tiles. Each tile is either dark (0) or bright (1).
When you tap a tile at (i,j), it toggles along with all orthogonally adjacent tiles (up, down, left, right) that exist within the grid.
Find the minimum number of taps to make all tiles bright, or determine that it is impossible.
Input
The first line contains t (1≤t≤20), the number of test cases.
Each test case consists of:
- The first line contains N and M (1≤N,M≤15).
- The next N lines contain M integers each (0 or 1).
The sum of N×M over all test cases does not exceed 500.
Output
For each test case, print the minimum number of taps, or −1 if impossible.