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