#include <bits/stdc++.h>
using namespace std;
const long long int N = 500005;
const long long int p = 31;
long long int lim = 100000;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int q;
  cin >> q;
  while (q--) {
    long long int n;
    cin >> n;
    long long int x[n + 1], y[n + 1];
    bool f1[n + 1], f2[n + 1], f3[n + 1], f4[n + 1];
    long long int minx = -lim;
    long long int miny = -lim;
    long long int maxx = lim;
    long long int maxy = lim;
    for (long long int i = 0; i < n; i++) {
      cin >> x[i] >> y[i] >> f1[i] >> f2[i] >> f3[i] >> f4[i];
      if (f1[i] == 0) {
        minx = max(minx, x[i]);
      }
      if (f2[i] == 0) {
        maxy = min(maxy, y[i]);
      }
      if (f3[i] == 0) {
        maxx = min(maxx, x[i]);
      }
      if (f4[i] == 0) {
        miny = max(miny, y[i]);
      }
    }
    if (minx > maxx || miny > maxy) {
      cout << 0 << endl;
    } else {
      cout << 1 << " ";
      cout << minx << " " << miny << endl;
    }
  }
  return 0;
}
