X Marks the Spot

Find the shortest integer direction so two movable perpendicular lines split the 4N points into four groups of N each.

Medium6GeometrySortingBrute forceNo attempts yetTime limit5sMemory limit512 MB

Problem

King Tyrone conquered the nation of Carrania, and his four sons immediately started to argue about how to split the land. The argument is about the gold mines. There are 4N4N of them, and each son must end up with exactly NN.

The king draws an X on the map. The X is a pair of perpendicular straight lines that cuts the nation into four parts, one part per son. No gold mine may lie on a border, and each of the four parts must contain exactly NN gold mines.

The direction of the X is written as an integer vector (dx,dy)(d_x, d_y). One border is a line with direction vector (dx,dy)(d_x, d_y), and the other border is a line with direction vector (dy,dx)(-d_y, d_x). The minister may put the intersection point of the two borders anywhere.

A vector (dx,dy)(d_x, d_y) is good if the two perpendicular lines with these directions can be placed so that no gold mine lies on a border and each of the four parts holds exactly NN gold mines.

Turning a direction vector by 9090 degrees or flipping its sign gives the same X, so only vectors with dx1d_x \ge 1, dx<dydx-d_x < d_y \le d_x and gcd(dx,dy)=1\gcd(d_x, |d_y|) = 1 are considered. Every X that has an integer direction vector has exactly one representative in this range.

Find the good vector with the smallest dx2+dy2d_x^2 + d_y^2. If several good vectors share that value, take the one with the smallest dyd_y.

Input

The first line contains the number of test cases TT. Each test case starts with a line containing NN, the number of gold mines each son must get. The next 4N4N lines each contain two integers xix_i and yiy_i, the coordinates of one gold mine.

Limits

  • 1T201 \le T \le 20
  • 1N2501 \le N \le 250
  • 106xi,yi106-10^6 \le x_i, y_i \le 10^6
  • No three gold mines are collinear.
  • A good vector with dx2+dy2200d_x^2 + d_y^2 \le 200 always exists.

Output

For each test case, print one line in the form Case #x: dx dy. Here xx is the test case number starting from 11, and dxd_x and dyd_y are the good vector with the smallest dx2+dy2d_x^2 + d_y^2, with ties broken by the smallest dyd_y.