#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int t, n, x[N], y[N], f[N][4], mnx, mny, mxx, mxy;
bool ok(int in) {
  if (f[in][0] == 0 && x[in] > mxx) return 0;
  if (f[in][1] == 0 && y[in] < mny) return 0;
  if (f[in][2] == 0 && x[in] < mnx) return 0;
  if (f[in][3] == 0 && y[in] > mxy) return 0;
  return 1;
}
int main() {
  cin >> t;
  while (t--) {
    mnx = mny = -1e5;
    mxx = mxy = 1e5;
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> x[i] >> y[i];
      int cnt = 0;
      for (int j = 0; j < 4; j++) {
        cin >> f[i][j];
        cnt += f[i][j];
      }
      if (cnt == 4) continue;
      if (f[i][0] == 0) {
        mnx = max(mnx, x[i]);
      }
      if (f[i][1] == 0) {
        mxy = min(mxy, y[i]);
      }
      if (f[i][2] == 0) {
        mxx = min(mxx, x[i]);
      }
      if (f[i][3] == 0) {
        mny = max(mny, y[i]);
      }
    }
    bool sol = 1;
    for (int i = 0; i < n; i++) {
      sol &= ok(i);
      if (sol == 0) break;
    }
    if (sol) {
      cout << "1 " << mnx << " " << mny << endl;
    } else
      cout << 0 << endl;
  }
  return 0;
}
