#include <bits/stdc++.h>
using namespace std;
void out(vector<long long> &a) {
  for (auto it = a.begin(); it != a.end(); ++it) cout << (*it) << " ";
  cout << endl;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << fixed << setprecision(20);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long minx = -1e5, maxx = 1e5, miny = -1e5, maxy = 1e5;
    for (long long i = 0; i < n; ++i) {
      long long x, y, f1, f2, f3, f4;
      cin >> x >> y >> f1 >> f2 >> f3 >> f4;
      if (!f1) minx = max(minx, x);
      if (!f2) maxy = min(maxy, y);
      if (!f3) maxx = min(maxx, x);
      if (!f4) miny = max(miny, y);
    }
    if (minx > maxx || miny > maxy)
      cout << "0\n";
    else
      cout << "1 " << minx << " " << miny << "\n";
  }
}
