Problem: You are given an array of size .
There is an grid. In the -th row, the first cells are black and the other cells are white. In other words, note as the cell in the -th row and -th column, cells are black, and cells are white.
You can do the following operations any number of times in any order:
- Dye a subgrid white;
- Dye a whole row white. Note you can not dye a whole column white.
Find the minimum number of operations to dye all cells white.
Input Format: The first line contains an integer () — the number of test cases.
For each test case:
- The first line contains an integer () — the size of the array .
- The second line contains integers ().
It's guaranteed that the sum of over all test cases will not exceed .
Output Format: For each test case, output a single integer — the minimum number of operations to dye all cells white.
Note: In the first test case, you don't need to do any operation.
In the second test case, you can do:
- Dye , and white;
- Dye , and white;
- Dye , and white.
It can be proven is the minimum number of operations.
In the third test case, you can do:
- Dye the first row white;
- Dye , and white.
It can be proven is the minimum number of operations.