#include <bits/stdc++.h>
using namespace std;
int q, n, x, y, f1, f2, f3, f4;
int main() {
  cin >> q;
  while (q--) {
    cin >> n;
    int lx = -100000, ly = -100000, rx = 100000, ry = 100000;
    for (int i = 0; i < n; i++) {
      scanf("%d%d%d%d%d%d", &x, &y, &f1, &f2, &f3, &f4);
      if (!f3) rx = min(rx, x);
      if (!f1) lx = max(lx, x);
      if (!f2) ry = min(ry, y);
      if (!f4) ly = max(ly, y);
    }
    if (lx > rx || ly > ry)
      cout << 0 << endl;
    else
      cout << "1 " << lx << " " << ly << endl;
  }
}
