#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long powmod(long long base, long long exp, long long MOD) {
  long long res = 1;
  while (exp > 0) {
    if (exp % 2 == 1) res = (res * base) % MOD;
    base = (base * base) % MOD;
    exp /= 2;
  }
  return (res % MOD);
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long q;
  cin >> q;
  while (q--) {
    long long n;
    cin >> n;
    vector<pair<long long, long long> > v1, v2, v3, v4;
    for (long long i = 0; i < n; i++) {
      long long x, y, a1, a2, a3, a4;
      cin >> x >> y >> a1 >> a2 >> a3 >> a4;
      v1.push_back({x, a3});
      v3.push_back({x, a1});
      v2.push_back({y, a2});
      v4.push_back({y, a4});
    }
    long long up = 1e5, down = -1e5, left = -1e5, right = 1e5;
    for (long long i = 0; i < n; i++) {
      if (v1[i].second == 0) up = min(up, v1[i].first);
      if (v3[i].second == 0) down = max(down, v3[i].first);
      if (v4[i].second == 0) left = max(left, v2[i].first);
      if (v2[i].second == 0) right = min(right, v4[i].first);
    }
    if (right >= left && up >= down)
      cout << 1 << ' ' << up << ' ' << right;
    else
      cout << 0;
    cout << '\n';
  }
  return 0;
}
