#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const int MxN = 200005;
const int mod = 1e9 + 7;
void pe(int a) { cout << a << "\n"; }
void pe(long long a) { cout << a << "\n"; }
void pe(string a) { cout << a << "\n"; }
void ps(int a) { cout << a << ' '; }
template <class T>
bool umin(T& a, const T& b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
bool umax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
long long nCr(long long n, long long r) {
  long long res = 1;
  if (r > n) return 0;
  if (r > n - r) r = n - r;
  for (long long i = 0; i < r; i++) {
    res *= (n - i);
    res /= (i + 1);
  }
  return res;
}
void solve() {
  int n;
  cin >> n;
  int lb = -1e5, rb = 1e5, ub = 1e5, db = -1e5;
  bool ans = 1;
  while (n--) {
    int x, y;
    cin >> x >> y;
    vector<int> m(4);
    for (int i = 0; i < 4; ++i) cin >> m[i];
    for (int i = 0; i < 4; ++i) {
      if (m[0] == 0) {
        lb = max(lb, x);
      }
      if (m[1] == 0) {
        ub = min(ub, y);
      }
      if (m[2] == 0) {
        rb = min(rb, x);
      }
      if (m[3] == 0) {
        db = max(db, y);
      }
      if (lb > rb || db > ub) {
        ans = 0;
      }
    }
  }
  if (ans) {
    ps(1);
    ps(lb);
    pe(ub);
  } else {
    pe(ans);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
