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