#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
const int maxn = 100010;
int n, m, k, t, t1, t2, t3, t4;
struct node {
  int x, y;
  int xd, xx, yd, yx;
} a[maxn];
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
      scanf("%d%d%d%d%d%d", &a[i].x, &a[i].y, &t1, &t2, &t3, &t4);
      if (t1 == 1) {
        a[i].xx = -100000;
      } else if (t1 == 0) {
        a[i].xx = a[i].x;
      }
      if (t2 == 1) {
        a[i].yd = 100000;
      } else if (t2 == 0) {
        a[i].yd = a[i].y;
      }
      if (t3 == 1) {
        a[i].xd = 100000;
      } else if (t3 == 0) {
        a[i].xd = a[i].x;
      }
      if (t4 == 1) {
        a[i].yx = -100000;
      } else if (t4 == 0) {
        a[i].yx = a[i].y;
      }
    }
    bool flag = true;
    int xmaxn = a[0].xd, xmin = a[0].xx, ymaxn = a[0].yd, ymin = a[0].yx;
    for (int i = 1; i < n; i++) {
      if (xmaxn < a[i].xx || xmin > a[i].xd || ymaxn < a[i].yx ||
          ymin > a[i].yd) {
        printf("0\n");
        flag = false;
        break;
      }
      if (xmaxn > a[i].xd) {
        xmaxn = a[i].xd;
      }
      if (xmin < a[i].xx) {
        xmin = a[i].xx;
      }
      if (ymaxn > a[i].yd) {
        ymaxn = a[i].yd;
      }
      if (ymin < a[i].yx) {
        ymin = a[i].yx;
      }
    }
    if (flag) {
      printf("1 %d %d\n", xmin, ymin);
    }
  }
  return 0;
}
