#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e5;
signed main() {
  long long q;
  cin >> q;
  for (long long w = 0; w < q; w++) {
    long long n;
    cin >> n;
    long long lx = -INF, rx = INF, ly = -INF, ry = INF;
    for (long long i = 0; i < n; i++) {
      long long x, y;
      cin >> x >> y;
      long long l, u, r, d;
      cin >> l >> u >> r >> d;
      if (!l) {
        lx = max(lx, x);
      }
      if (!u) {
        ry = min(ry, y);
      }
      if (!r) {
        rx = min(rx, x);
      }
      if (!d) {
        ly = max(ly, y);
      }
    }
    if (lx > rx || ly > ry) {
      cout << 0 << endl;
    } else {
      cout << 1 << " " << lx << " " << ly << endl;
    }
  }
  return 0;
}
