#include <bits/stdc++.h>
using namespace std;
static const int MAX_N = 2e5 + 5;
static const int Mod = 10007;
void input() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
void mainwork() {
  int q;
  scanf("%d", &q);
  while (q--) {
    int n;
    scanf("%d", &n);
    int minx = -1e5, miny = -1e5, maxx = 1e5, maxy = 1e5;
    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(x, minx);
      if (!f2) maxy = min(y, maxy);
      if (!f3) maxx = min(x, maxx);
      if (!f4) miny = max(y, miny);
    }
    if (minx <= maxx && miny <= maxy)
      printf("1 %d %d\n", minx, miny);
    else
      puts("0");
  }
}
int main() {
  mainwork();
  return 0;
}
