#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  scanf("%d", &q);
  while (q--) {
    int n;
    scanf("%d", &n);
    int xl = -1e9, xr = 1e9;
    int yd = -1e9, yu = 1e9;
    bool flag = true;
    for (int i = 0; i < n; i++) {
      int x, y, l, u, r, d;
      scanf("%d%d%d%d%d%d", &x, &y, &l, &u, &r, &d);
      if (!l) {
        if (xr < x) {
          flag = false;
        } else {
          xl = max(xl, x);
        }
      }
      if (!u) {
        if (yd > y) {
          flag = false;
        } else {
          yu = min(yu, y);
        }
      }
      if (!r) {
        if (xl > x) {
          flag = false;
        } else {
          xr = min(xr, x);
        }
      }
      if (!d) {
        if (yu < y) {
          flag = false;
        } else {
          yd = max(yd, y);
        }
      }
    }
    if (!flag || xl > xr || yd > yu) {
      puts("0");
    } else {
      xl = max(xl, -100000);
      xr = min(xr, 100000);
      yu = min(yu, 100000);
      yd = max(yd, -100000);
      printf("1 %d %d\n", xl, yd);
    }
  }
  return 0;
}
