Meet and Party (Large)

Pick an invited home inside the given rectangles that minimizes the total Manhattan distance walked by all guests and report its coordinates and the sum.

Medium6SortingPrefix sumMathNo attempts yetTime limit5sMemory limit512 MB

Problem

Sin lives in a city laid out as a grid. The city is a 2D plane, and people move only north, south, east or west along the grid lines. The distance from (x1,y1)(x_1, y_1) to (x2,y2)(x_2, y_2) is x1x2+y1y2|x_1 - x_2| + |y_1 - y_2|.

Sin wants to throw a house party this Sunday. The guest list is already settled, so all that is left is choosing whose home hosts the party.

Sin picked a few rectangular areas and invited everyone living inside them, and every invited person said yes. A rectangular area is given by four integers (x1,y1,x2,y2)(x_1, y_1, x_2, y_2) with x1x2x_1 \le x_2 and y1y2y_1 \le y_2. One person lives at every lattice point of the area, so the area (x1,y1,x2,y2)(x_1, y_1, x_2, y_2) holds (x2x1+1)×(y2y1+1)(x_2 - x_1 + 1) \times (y_2 - y_1 + 1) people.

The party has to be held at the home of one of the attendees. Sin wants to minimize the sum of the distances every attendee walks from home to the party. Find that home.

Input

The first line contains the number of test cases TT. The first line of each test case contains the number of rectangular areas BB. Each of the next BB lines contains four integers x1x_1, y1y_1, x2x_2, y2y_2 separated by spaces, the coordinates of a rectangular area of people Sin invited.

Output

For each test case, print one line in the form "Case #t: x y d", where tt is the test case number starting from 1, (x,y)(x, y) is the home that hosts the party, and dd is the sum of the distances every attendee walks to that home.

If several homes give the same minimum sum, pick the one with the smallest xx. If several still remain, pick the one with the smallest yy among them.

Constraints

  • 1T101 \le T \le 10
  • 1B10001 \le B \le 1000
  • x1,y1,x2,y2109|x_1|, |y_1|, |x_2|, |y_2| \le 10^9
  • x1x2x_1 \le x_2, y1y2y_1 \le y_2
  • The rectangular areas within one test case do not overlap.
  • The total number of people in one test case is at least 11 and at most 10610^6.