#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize(3)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("sse3", "sse2", "sse")
#pragma GCC target("avx", "sse4", "sse4.1", "sse4.2", "ssse3")
#pragma GCC target("f16c")
#pragma GCC optimize("inline", "fast-math", "unroll-loops", \
                     "no-stack-protector")
using namespace std;
const int N = 1e5 + 10;
const int M = 150;
const int INF = 0x3f3f3f3f;
const int MOD = 998244353;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ;
  int T;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    int minx = -100000, maxx = 100000, miny = -100000, maxy = 100000;
    for (int i = 0; i < n; i++) {
      int first, second, l, r, u, d;
      cin >> first >> second >> l >> u >> r >> d;
      if (!l) minx = max(minx, first);
      if (!u) maxy = min(maxy, second);
      if (!r) maxx = min(maxx, first);
      if (!d) miny = max(miny, second);
    }
    if (minx <= maxx && miny <= maxy) {
      cout << "1" << ' ' << minx << ' ' << miny << endl;
    } else {
      cout << "0" << endl;
    }
  }
  return 0;
}
