#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e5;
const long long N = 1e6 + 10;
long long q;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> q;
  for (int al = 0; al < q; al++) {
    long long n, maxu = (-1) * INF, mind = INF, minl = INF, maxr = (-1) * INF,
                 x1, y1;
    cin >> n;
    for (int i = 0; i < n; i++) {
      long long x, y, f1, f2, f3, f4;
      cin >> x >> y >> f1 >> f2 >> f3 >> f4;
      x1 = x;
      y1 = y;
      if (f1 == 0) maxr = max(maxr, x);
      if (f2 == 0) mind = min(mind, y);
      if (f3 == 0) minl = min(minl, x);
      if (f4 == 0) maxu = max(maxu, y);
    }
    if ((maxu != (-1) * INF && mind != INF)) {
      if (maxu > mind) {
        cout << 0 << endl;
        continue;
      }
    }
    if ((maxr != (-1) * INF && minl != INF)) {
      if (maxr > minl) {
        cout << 0 << endl;
        continue;
      }
    }
    cout << 1 << " " << maxr << " " << maxu << endl;
  }
  return 0;
}
