#include <bits/stdc++.h>
using namespace std;
vector<bool> sieve(long long n) {
  vector<bool> prime(n + 1, true);
  prime[0] = prime[1] = false;
  for (long long i = 2; i <= n; ++i) {
    if (prime[i] && (i * i) <= n)
      for (long long j = i * i; j <= n; j += i) prime[j] = false;
  }
  return prime;
}
long long power(long long a, long long b, long long m = 1000000007) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return res;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    pair<long long, long long> x, y;
    x.first = -100000;
    x.second = 100000;
    y.first = -100000;
    y.second = 100000;
    bool ok = 1;
    for (long long i = 0; i < n; ++i) {
      long long tempx, tempy;
      cin >> tempx >> tempy;
      long long l, u, r, d;
      cin >> l >> u >> r >> d;
      if (l == 0) x.first = max(x.first, tempx);
      if (r == 0) x.second = min(x.second, tempx);
      if (u == 0) y.second = min(y.second, tempy);
      if (d == 0) y.first = max(y.first, tempy);
      if (x.first > x.second || y.first > y.second) ok = -0;
    }
    if (!ok)
      cout << "0\n";
    else
      cout << "1 " << x.first << " " << y.first << '\n';
  }
  return 0;
}
