#include <bits/stdc++.h>
using namespace std;
int T, n, qqq, www, eee, rrr, x, y, as[11];
int main() {
  scanf("%d", &T);
  while (T--) {
    qqq = www = 1e5;
    eee = rrr = -1e5;
    scanf("%d", &n);
    while (n--) {
      scanf("%d %d %d %d %d %d", &x, &y, &as[0], &as[1], &as[2], &as[3]);
      if (!as[0])
        if (x > eee) eee = x;
      if (!as[1])
        if (y < www) www = y;
      if (!as[2])
        if (x < qqq) qqq = x;
      if (!as[3])
        if (y > rrr) rrr = y;
    }
    if (eee <= qqq && rrr <= www)
      printf("1 %d %d\n", eee, rrr);
    else
      printf("0\n");
  }
  return 0;
}
