#include <bits/stdc++.h>
using namespace std;
int getmax(int x, int y) {
  if (x > y)
    return x;
  else
    return y;
}
int getmin(int x, int y) {
  if (x < y)
    return x;
  else
    return y;
}
int main() {
  int q;
  scanf("%d", &q);
  while (q--) {
    int x0 = -100000;
    int y0 = -100000;
    int x1 = 100000;
    int y1 = 100000;
    int n;
    scanf("%d", &n);
    while (n--) {
      int x, y;
      scanf("%d%d", &x, &y);
      int f1, f2, f3, f4;
      scanf("%d%d%d%d", &f1, &f2, &f3, &f4);
      if (f1 == 0) x0 = getmax(x, x0);
      if (f2 == 0) y1 = getmin(y, y1);
      if (f3 == 0) x1 = getmin(x, x1);
      if (f4 == 0) y0 = getmax(y, y0);
    }
    if (x0 <= x1 && y0 <= y1) {
      printf("1 %d %d\n", x0, y0);
    } else
      printf("0\n");
  }
  return 0;
}
