In this morning, my roommate H’s female friend asked him for help.Through my analysis, the girl was taking an examination… .What terrible means the girl was using!The girl begged my roommate H to help her to pass the examination and show how important the examination is to her constantly.But my roommate H was not clever enough to solve the problem and ask for my aid.Out of humanitarian and pure friendship between H and me, I decided to help this poor and desperate girl.The girl sent the promble to me and told me that there were only ten minutes left… .I took a look at the problem and found that the problem is very easy.It model of the problem is just to find the maximum matching in a bipartite graph.The description of the promble is below:
Description
There are many black points B={b1,b2,……,bn} and white points W={w1,w2,……,wm} in plane.A black point bi=(xi,yi) match a white point wj=(xj,yj) if and only if xi<=xj and yi<=yj.Futhermore a point can only match to one point in opposite colour.The problem is to find out the maximum number of matching conforming to the rules above.
Input Format
The first line includes an integer T represents there are T cases;
In each case, the first line has two integers n, m represent the number of black points and white points;
Then there is n+m lines and each line has two integers represent the coordinate of black points or white points.
Code
|
|
Samples
Sample Input
2
2 2
1 0
0 1
1 1
0 0
1 1
1 1
0 0
Sample Output
1
0
Plot Followed
Unfortunately, I just right used ten minutes to solve the promble and my PC is run on Ubuntu system.So I sent the code file to my roommate H by E-mail and he used QQ to sent the code file to the poor girl.This process totally spent about eleven minutes.That means it was just one minute after the end of examination when the girl recieved the code file.
The girl said me that she felt said that she failed the important examination but thanks a lot for my great help.She said she had never thought there would be anyone help she without any rewards or aims.But I considered the girl was too young too naive.As the old saying, there isn’t any love and hate without any reason, so do my assistance.I helped you because
I just thought the problem was a little interesting and wanna solve it, hhha (●°u°●) 」