Optimal Point

When the river brought Gerda to the house of the Old Lady who Knew Magic, this lady decided to make Gerda her daughter. She wants Gerda to forget about Kay, so she puts all the roses from the garden underground.

Mole, who lives in this garden, now can watch the roses without going up to the surface. Typical mole is blind, but this mole was granted as special vision by the Old Lady. He can watch any underground objects on any distance, even through the obstacles and other objects. However, the quality of the picture depends on the Manhattan distance to object being observed.

Mole wants to find an optimal point to watch roses, that is such point with integer coordinates that the maximum Manhattan distance to the rose is minimum possible.

As usual, he asks you to help.

Manhattan distance between points (x 1,  y 1,  z 1) and (x 2,  y 2,  z 2) is defined as |x 1 - x 2| + |y 1 - y 2| + |z 1 - z 2|.

Input

The first line of the input contains an integer t t (1 ≤ t ≤ 100 000) — the number of test cases. Then follow exactly t blocks, each containing the description of exactly one test.

The first line of each block contains an integer n i (1 ≤ n i ≤ 100 000) — the number of roses in the test. Then follow n i lines, containing three integers each — the coordinates of the corresponding rose. Note that two or more roses may share the same position.

It’s guaranteed that the sum of all n i doesn’t exceed 100 000 and all coordinates are not greater than 1018 by their absolute value.

Output

For each of t test cases print three integers — the coordinates of the optimal point to watch roses. If there are many optimal answers, print any of them.

The coordinates of the optimal point may coincide with the coordinates of any rose.

Examples

input

1
5
0 0 4
0 0 -4
0 4 0
4 0 0
1 1 1

output

0 0 0

input

2
1
3 5 9
2
3 5 9
3 5 9

output

3 5 9
3 5 9

Note

In the first sample, the maximum Manhattan distance from the point to the rose is equal to 4.

In the second sample, the maximum possible distance is 0. Note that the positions of the roses may coincide with each other and with the position of the optimal point.

Solution:

#include <bits/stdc++.h>

using namespace std;

const long long bmax = (long long) 3.01e18;
const long long inf  = (long long) 9.01e18;

const int N = 1234567;

long long x[N], y[N], z[N];
long long the_x, the_y, the_z;

int main() {
int tt;
scanf("%d", &tt);
while (tt--) {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
      scanf("%I64d %I64d %I64d", x + i, y + i, z + i);
    }
    the_x = the_y = the_z = -1;
    long long low = 0, high = bmax;
    while (low < high) {
      long long mid = (low + high) >> 1;
long long a = -inf, b = inf;
long long c = -inf, d = inf;
long long e = -inf, f = inf;
long long g = -inf, h = inf;
for (int i = 0; i < n; i++) {
        a = max(a, x[i] + y[i] + z[i] - mid);
        b = min(b, x[i] + y[i] + z[i] + mid);
        c = max(c, x[i] + y[i] - z[i] - mid);
        d = min(d, x[i] + y[i] - z[i] + mid);
        e = max(e, x[i] - y[i] + z[i] - mid);
        f = min(f, x[i] - y[i] + z[i] + mid);
        g = max(g, x[i] - y[i] - z[i] - mid);
        h = min(h, x[i] - y[i] - z[i] + mid);
      }
      bool ok = false;
      if (a > b || c > d || e > f || g > h) {
// do nothing
} else {
long long from_x = max(a + g, c + e);
long long to_x = min(d + f, b + h);
if (from_x & 1) {
from_x++;
}
if (to_x & 1) {
to_x--;
}
from_x /= 2;
to_x /= 2;
if (from_x <= to_x) {
          for (long long x = from_x; x <= to_x; x++) {
            long long from_plus = max(a - x, -h + x);
            long long to_plus = min(b - x, -g + x);
            long long from_minus = max(c - x, -f + x);
            long long to_minus = min(d - x, -e + x);
            if (from_plus <= to_plus && from_minus <= to_minus) {
              if (from_plus < to_plus || from_minus < to_minus || ((from_plus & 1) == (from_minus & 1))) {
                if ((from_plus & 1) != (from_minus & 1)) {
                  if (from_plus < to_plus) {
                    from_plus++;
                  } else {
                    from_minus++;
                  }
                }
                long long ypz = from_plus;
                long long ymz = from_minus;
                the_x = x;
                the_y = (ypz + ymz) / 2;
                the_z = (ypz - ymz) / 2;
                ok = true;
                break;
              }
            }
            if (x == from_x + 2 && x < to_x - 3) {
              x = to_x - 3;
            }
          }
        }
      }
      if (ok) {
        high = mid;
      } else {
        low = mid + 1;
      }
    }
    printf("%I64d %I64d %I64d\n", the_x, the_y, the_z);
  }
  return 0;
}