spoj#DIVCON. Divide and Conquer
Divide and Conquer
Anne and Brenda found some cookies scattered on the lattice points in the 2D coordinate system. They agreed to divide them in the following manner.
First, Anne draws a vertical line (that is, a line with the equation x = c, for any real number c) somewhere in the plane. Then Brenda draws a horizontal line (y = d) somewhere in the plane. Now they have divided the plane in four quadrants.
Anne gets all the cookies lying in the upper right and the lower left quadrant, and Brenda gets all the cookies lying in the upper left and the lower right quadrant. Cookies which lie on the vertical or the horizontal line are ignored.
Anne's goal is to maximize the number of cookies she gets, knowing that Brenda plays optimally (in order to maximize her number of cookies).
Input
In the first line of input there is an integer T (1 ≤ T ≤ 600), the number of test cases.
Each test case starts with an integer N (1 ≤ N ≤ 1000), the number of cookies. In the next N lines there are coordinates (Xi, Yi) of the cookies, integers in the interval [1, 1000]. There can be multiple cookies at the same point.
Output
For each of the T cases, output in a separate line the maximal number of cookies Anne can surely get.
Example
Input: 2
5
1 1
4 1
4 5
5 1
3 3
11
7 10
7 11
7 10
7 11
6 6
5 5
4 8
1 5
1 6
1 4
7 1
Output: 2
5