#include <bits/stdc++.h>
using namespace std;
long long int pw(long long int a, long long int p,
                 long long int m = 1000000007) {
  if (p == 1) return a;
  long long int t = pw(a, p / 2);
  t = (m + (t * t) % m) % m;
  if (p % 2 != 0) t *= a;
  return (t + m) % m;
}
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> x(n), y(n), left(n), up(n), right(n), down(n);
  for (long long int i = 0; i < (n); i++)
    cin >> x[i] >> y[i] >> left[i] >> up[i] >> right[i] >> down[i];
  long long int ad = 100000;
  long long int xl = -ad, yu = ad, xr = ad, yd = -ad;
  for (long long int i = 0; i < (n); i++) {
    if (left[i] == 0) xl = max(x[i], xl);
    if (up[i] == 0) yu = min(y[i], yu);
    if (right[i] == 0) xr = min(x[i], xr);
    if (down[i] == 0) yd = max(y[i], yd);
  }
  if (xl <= xr && yd <= yu)
    cout << "1 " << xl << " " << yd << endl;
  else
    cout << "0\n";
}
int main() {
  ios::sync_with_stdio(0);
  long long int t = 1;
  cin >> t;
  for (long long int i = 0; i < (t); i++) solve();
}
