#include <bits/stdc++.h>
using namespace std;
vector<int> v(2001);
void print(vector<int> v) {
  vector<int>::iterator it = v.begin();
  while (it != v.end()) {
    cout << *it << " ";
    it++;
  }
  cout << endl;
}
void printq(queue<int> q) {
  if (q.size() == 0)
    return;
  else {
    long long x = q.front();
    q.pop();
    printq(q);
    cout << x << " ";
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    vector<bool> fl(n);
    vector<bool> fr(n);
    vector<bool> fu(n);
    vector<bool> fd(n);
    int mni = 0;
    int mnm = 5;
    for (int i = 0; i < n; i++) {
      int a, b;
      bool l, r, u, d;
      cin >> a >> b >> l >> u >> r >> d;
      if ((l + r + u + d) < mnm) {
        mni = i;
        mnm = l + r + u + d;
      }
      x[i] = a;
      y[i] = b;
      fl[i] = l;
      fr[i] = r;
      fu[i] = u;
      fd[i] = d;
    }
    int xp, xn, yp, yn;
    xp = xn = x[mni];
    yp = yn = y[mni];
    if (fl[mni] == 1) {
      xn = -100000;
    }
    if (fr[mni] == 1) {
      xp = 100000;
    }
    if (fu[mni] == 1) {
      yp = 100000;
    }
    if (fd[mni] == 1) {
      yn = -100000;
    }
    int deb = 0;
    for (int i = 0; i < n; i++) {
      if (i == mni)
        continue;
      else {
        int xpp, xnn, ypp, ynn;
        xpp = xnn = x[i];
        ypp = ynn = y[i];
        if (fl[i] == 1) {
          xnn = -100000;
        }
        if (fr[i] == 1) {
          xpp = 100000;
        }
        if (fu[i] == 1) {
          ypp = 100000;
        }
        if (fd[i] == 1) {
          ynn = -100000;
        }
        if ((xnn > xp && xpp > xp) || (xpp < xn && xnn < xn)) {
          deb = 1;
          break;
        }
        if ((ynn > yp && ypp > yp) || (ypp < yn && ynn < yn)) {
          deb = 1;
          break;
        }
        xp = min(xp, xpp);
        xn = max(xnn, xn);
        yp = min(yp, ypp);
        yn = max(yn, ynn);
      }
    }
    if (deb == 1)
      cout << 0 << endl;
    else
      cout << 1 << " " << xp << " " << yp << endl;
  }
}
