#include <bits/stdc++.h>
using namespace std;
const int INF = 1e5;
const int maxn = 1e5 + 7;
int n;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    int maxx = -INF;
    int minx = INF;
    int maxy = -INF;
    int miny = INF;
    int x, y, f1, f2, f3, f4;
    for (int i = 1; i <= n; i++) {
      scanf("%d%d%d%d%d%d", &x, &y, &f1, &f2, &f3, &f4);
      if (!f1) maxx = max(maxx, x);
      if (!f2) miny = min(miny, y);
      if (!f3) minx = min(minx, x);
      if (!f4) maxy = max(maxy, y);
    }
    if (maxx > minx || maxy > miny)
      printf("0\n");
    else
      printf("1 %d %d\n", maxx, maxy);
  }
  return 0;
}
