#include <bits/stdc++.h>
using namespace std;
using cd = complex<double>;
const long long modd1 = 1e9 + 7, modd2 = 998244353, maxn = 1e5 + 2, K = 26,
                inf = 1e9, infll = 1e18;
const double pi = acos(-1);
long long x[maxn], y[maxn], f[5][maxn];
void solve() {
  long long t;
  cin >> t;
  while (t--) {
    long long n, i, j, k, l, r;
    cin >> n;
    long long mxx = LLONG_MIN, mnx = LLONG_MAX, mny = LLONG_MAX,
              mxy = LLONG_MIN;
    for (i = 1; i <= n; ++i) {
      cin >> x[i] >> y[i] >> f[1][i] >> f[2][i] >> f[3][i] >> f[4][i];
      mxx = max(mxx, x[i]);
      mnx = min(mnx, x[i]);
      mny = min(mny, y[i]);
      mxy = max(mxy, y[i]);
    }
    for (i = 1; i <= n; ++i) {
      if (!f[1][i]) {
        mnx = max(mnx, x[i]);
      }
      if (!f[2][i]) {
        mxy = min(mxy, y[i]);
      }
      if (!f[3][i]) {
        mxx = min(mxx, x[i]);
      }
      if (!f[4][i]) {
        mny = max(mny, y[i]);
      }
    }
    if (mnx > mxx || mny > mxy) {
      cout << 0 << '\n';
    } else {
      cout << 1 << ' ' << mnx << ' ' << mny << '\n';
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}
