#include <bits/stdc++.h>
using namespace std;
int check(int maxx, int x, int pos) {
  if (!pos)
    return min(maxx, x);
  else
    return max(maxx, x);
}
int main() {
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    pair<int, int> p[n];
    int arr[n][4];
    bool pos = 1;
    int minX = -1e5, maxX = 1e5, minY = -1e5, maxY = 1e5;
    for (int i = 0; i < n; i++) {
      int x, y;
      cin >> x >> y;
      p[i].first = x, p[i].second = y;
      for (int j = 0; j < 4; j++) {
        cin >> arr[i][j];
        if (!arr[i][j]) {
          if (j == 0) {
            if (minX > x)
              pos = 0;
            else
              minX = x;
          }
          if (j == 1) {
            if (maxY < y)
              pos = 0;
            else
              maxY = y;
          }
          if (j == 2) {
            if (maxX < x)
              pos = 0;
            else
              maxX = x;
          }
          if (j == 3) {
            if (minY > y)
              pos = 0;
            else
              minY = y;
          }
        }
      }
    }
    if (minX <= maxX && maxY >= minY)
      cout << 1 << " " << minX << " " << minY << endl;
    else
      cout << 0 << endl;
  }
}
