#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
template <class T>
inline void chmax(T &a, const T &b) {
  if ((a) < (b)) (a) = (b);
}
template <class T>
inline void chmin(T &a, const T &b) {
  if ((a) > (b)) (a) = (b);
}
template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast {
  Fast() {
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
long long query() {
  long long n;
  cin >> n;
  vector<long long> x(n);
  vector<long long> y(n);
  vector<long long> L(n);
  vector<long long> U(n);
  vector<long long> R(n);
  vector<long long> D(n);
  long long l = -1e5;
  long long r = 1e5;
  long long d = -1e5;
  long long u = 1e5;
  for (long long i = (long long)(0); i < (long long)(n); ++i) {
    cin >> x[i] >> y[i] >> L[i] >> U[i] >> R[i] >> D[i];
    if (L[i] == 1 && R[i] == 1) {
    }
    if (L[i] == 0 && R[i] == 1) {
      chmax(l, x[i]);
    }
    if (L[i] == 1 && R[i] == 0) {
      chmin(r, x[i]);
    }
    if (L[i] == 0 && R[i] == 0) {
      chmax(l, x[i]);
      chmin(r, x[i]);
    }
    if (D[i] == 1 && U[i] == 1) {
    }
    if (D[i] == 0 && U[i] == 1) {
      chmax(d, y[i]);
    }
    if (D[i] == 1 && U[i] == 0) {
      chmin(u, y[i]);
    }
    if (D[i] == 0 && U[i] == 0) {
      chmax(d, y[i]);
      chmin(u, y[i]);
    }
  }
  42;
  42;
  if (l <= r && d <= u) {
    42;
    printf("1 %lld %lld\n", l, d);
  } else {
    printf("0\n");
  }
  return 0;
}
long long solve() {
  long long Q;
  cin >> Q;
  for (long long q = (long long)(0); q < (long long)(Q); ++q) {
    query();
  }
  return 0;
}
signed main() {
  solve();
  return 0;
}
