#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 100;
int n, a[4];
struct Point {
  long long x[3];
  Point() {}
  void read() {
    for (a[1] = 0; a[1] < 3; ++a[1]) cin >> x[a[1]];
  }
} p[maxN];
long long dis(Point x) {
  long long ret = 0;
  for (int a = 0; a < n; ++a) {
    ret = max(ret, abs(p[a].x[0] - x.x[0]) + abs(p[a].x[1] - x.x[1]) +
                       abs(p[a].x[2] - x.x[2]));
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tCase;
  cin >> tCase;
  while (tCase--) {
    cin >> n;
    for (a[0] = 0; a[0] < n; ++a[0]) p[a[0]].read();
    if (n == 1) {
      for (a[1] = 0; a[1] < 3; ++a[1]) cout << p[0].x[a[1]] << ' ';
      cout << endl;
      continue;
    }
    Point tp;
    long long maxDis = dis(tp);
    long long stp = (long long)1e18 + 514;
    while (stp) {
      bool chg = false;
      a[0] = a[1] = a[2] = 0;
      Point dp;
      for (a[0] = -1; a[0] <= 1 && !chg; ++a[0]) {
        dp.x[0] = tp.x[0] + a[0] * stp;
        for (a[1] = -1; a[1] <= 1 && !chg; ++a[1]) {
          dp.x[1] = tp.x[1] + a[1] * stp;
          for (a[2] = -1; a[2] <= 1 && !chg; ++a[2]) {
            dp.x[2] = tp.x[2] + a[2] * stp;
            long long dd = dis(dp);
            if (dd < maxDis) {
              maxDis = dd;
              tp = dp;
              chg = true;
            }
          }
        }
      }
      if (!chg) stp /= 2;
    }
    for (a[1] = 0; a[1] < 3; ++a[1]) cout << tp.x[a[1]] << ' ';
    cout << endl;
  }
  return 0;
}
