#include <bits/stdc++.h>
using namespace std;
long long int primes[] = {2,  3,  5,  7,  11, 13, 17, 19, 23, 29, 31, 37,
                          41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89};
string alpha = "abcdefghijklmnopqrstuvwxyz";
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    long long int xmin, XMAX, ymin, YMAXIMUM;
    xmin = ymin = -100000;
    XMAX = YMAXIMUM = 100000;
    bool isPOSSIBLE = false;
    for (long long int i = 0; i < n; i++) {
      long long int x, y, u, d, r, l;
      long long int lx, rx, YU, YD;
      cin >> x >> y >> l >> u >> r >> d;
      l ? lx = -100000 : lx = x;
      r ? rx = 100000 : rx = x;
      u ? YU = 100000 : YU = y;
      d ? YD = -100000 : YD = y;
      if (rx < xmin || lx > XMAX || YU < ymin || YD > YMAXIMUM)
        isPOSSIBLE = true;
      xmin = max(xmin, lx);
      ymin = max(ymin, YD);
      XMAX = min(XMAX, rx);
      YMAXIMUM = min(YMAXIMUM, YU);
    }
    if (isPOSSIBLE)
      cout << 0 << "\n";
    else
      cout << 1 << " " << XMAX << " " << YMAXIMUM << "\n";
  }
  return 0;
}
