#Lutece1455. Master Zhu
Master Zhu
Migrated from Lutece 1455 Master Zhu
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
Master Zhu has an chessboard. In the -th row, the squares from the -th column to the -th 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 chessmen he should place.
Input
There are multiple test cases. The first line of input contains an integer , indicating the number of test cases.
For each test case, the first line contains two integers and -- the number of rows and columns. For the next lines, each line two integers .
Output
For each test case, output the minimum number of chessmen he should place.
Samples
3
3 3
1 1
2 2
3 3
2 4
1 3
2 4
3 2
1 2
1 2
1 2
3
2
2
Resources
2016 Multi-University Training Contest 6