#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const double PI = 3.14159265;
string add(string s1, string s2) {
  reverse(s1.begin(), s1.end());
  reverse(s2.begin(), s2.end());
  string ss = "";
  int i = 0, j = 0, nxt = 0;
  while (i < s1.size() || j < s2.size() || nxt) {
    int temp = (i < s1.size() ? s1[i] - '0' : 0) +
               (j < s2.size() ? s2[j] - '0' : 0) + nxt;
    ss.push_back(temp % 10 + '0');
    nxt = temp / 10;
    i++, j++;
  }
  reverse(ss.begin(), ss.end());
  return ss;
}
void yes() { cout << "YES" << '\n'; }
void no() { cout << "NO" << '\n'; }
bool cmp(const pair<int, string> &a, const pair<int, string> &b) {
  return (a.first > b.first);
}
long long int ceil(long long int x, long long int y) {
  return x % y ? x / y + 1 : x / y;
}
long long int power(long long int x, long long int y, long long int mo) {
  long long int r = 1;
  x = x % mo;
  while (y) {
    if (y & 1) r = (r * x % mo) % mo;
    y = y >> 1;
    x = ((x % mo) * (x % mo)) % mo;
  }
  return r % mo;
}
long long int gcd(long long int x, long long int y) {
  return y ? gcd(y, x % y) : x;
}
long long int fac(long long int x) { return (x ? x * fac(x - 1) : 1); }
long long int inv(long long int x, long long int y) {
  return (x * power(y, mod - 2, mod)) % mod;
}
long long int Twafiq(int n, int r) {
  long long int res = fac(n);
  long long int div = fac(n - r) * fac(r);
  div %= mod;
  div = power(div, mod - 2, mod);
  return (res * div) % mod;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  int q;
  cin >> q;
  while (q--) {
    long long int n, x, y, f1, f2, f3, f4;
    cin >> n;
    long long int mnx = -100000, mxx = 100000, mny = -100000, mxy = 100000;
    while (n--) {
      cin >> x >> y >> f1 >> f2 >> f3 >> f4;
      if (f1 == 0) {
        mnx = max(mnx, x);
      }
      if (f2 == 0) {
        mxy = min(mxy, y);
      }
      if (f3 == 0) {
        mxx = min(mxx, x);
      }
      if (f4 == 0) {
        mny = max(mny, y);
      }
    }
    if (mxx < mnx || mxy < mny)
      cout << 0 << '\n';
    else
      cout << 1 << ' ' << mnx << ' ' << mny << '\n';
  }
  return 0;
}
