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