#include <bits/stdc++.h>
using namespace std;
int a[100005], b[100005];
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    int z, y, s, x;
    int z1 = -100000, y1 = 100000, s1 = 100000, x1 = -100000;
    for (int i = 1; i <= n; i++) {
      scanf("%d%d%d%d%d%d", &a[i], &b[i], &z, &s, &y, &x);
      if (z == 0) z1 = max(a[i], z1);
      if (y == 0) y1 = min(a[i], y1);
      if (s == 0) s1 = min(b[i], s1);
      if (x == 0) x1 = max(b[i], x1);
    }
    if (y1 < z1 || x1 > s1)
      printf("0\n");
    else
      printf("1 %d %d\n", z1, s1);
  }
}
