#include <bits/stdc++.h>
using namespace std;
struct V {
  long long x, y, z;
  long long operator-(const V &A) const {
    return abs(x - A.x) + abs(y - A.y) + abs(z - A.z);
  }
  void read() { scanf("%I64d%I64d%I64d", &x, &y, &z); }
  void print() { printf("%I64d %I64d %I64d\n", x, y, z); }
  V walk(int a, int b, int c, long long d) {
    V Q;
    Q.x = x + d * a;
    Q.y = y + d * b;
    Q.z = z + d * c;
    return Q;
  }
} s[101000], A, T;
int n;
long long a, t;
long long d(V &X) {
  long long res = 0;
  for (int i = 1; i <= n; i++) res = max(res, X - s[i]);
  return res;
}
int main() {
  int U, i, j, k;
  for (scanf("%d", &U); U--;) {
    scanf("%d", &n);
    for (i = 1; i <= n; i++) s[i].read();
    if (n == 1) {
      s[1].print();
      continue;
    }
    A.x = A.y = A.z = 0;
    a = d(A);
    for (long long D = (long long)1e18; D;) {
      bool f = 1;
      for (i = -1; i <= 1 && f; i++)
        for (j = -1; j <= 1 && f; j++)
          for (k = -1; k <= 1 && f; k++) {
            if (!i && !j && !k) continue;
            t = d(T = A.walk(i, j, k, D));
            if (a > t) A = T, a = t, f = 0;
          }
      if (f) D >>= 1;
    }
    A.print();
  }
  return 0;
}
