#P11056. [2016杭电多校]Master Zhu
[2016杭电多校]Master Zhu
Master Zhu
Problem Description
Master Zhu has a chess-board.In the Ith row,the squares from the column to the column is colored by black,and others are colored by white.Besides,it guarantees that .Now Master Zhu is going to place some chessmans on serval black square,so that for each black square there are at least one chessman in its row or its column.Then he ask you the minimum number of chessmans he should place.
Input
There are multiple test cases. The first line of input contains an integer T, indicating the number of test cases. For each test case,The first line contains two integers and -- the number of rows and column. For the next n lines,each line two integers .
Output
For each test case, output the min minimum number of chessmans he should place.
Sample Input
3
3 3
1 1
2 2
3 3
2 4
1 3
2 4
3 2
1 2
1 2
1 2
Sample Output
3
2
2
Author
UESTC
Source
2016 Multi-University Training Contest 6