#include <bits/stdc++.h>
using namespace std;
;
const long long INF = 1e9 + 7;
const int N = 2e5 + 10;
int main() {
  int ncase;
  cin >> ncase;
  while (ncase--) {
    int n;
    cin >> n;
    int lx, rx, ly, ry;
    lx = ly = -1e5;
    rx = ry = 1e5;
    while (n--) {
      int a, b, c, d;
      int x, y;
      cin >> x >> y;
      cin >> a >> b >> c >> d;
      if (!a) lx = max(lx, x);
      if (!c) rx = min(rx, x);
      if (!d) ly = max(ly, y);
      if (!b) ry = min(ry, y);
    }
    if (lx > rx || ly > ry)
      puts("0");
    else
      printf("1 %d %d\n", lx, ly);
  }
  return 0;
}
