#include <bits/stdc++.h>
using namespace std;
const int M = (int)1e5;
int main() {
  ios_base ::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, i, mnx = -M, mxx = M, mny = -M, mxy = M, x, y, a, b, c, d;
    cin >> n;
    bool pos = true;
    while (n--) {
      cin >> x >> y >> a >> b >> c >> d;
      if (a == 0) mnx = max(mnx, x);
      if (b == 0) mxy = min(mxy, y);
      if (c == 0) mxx = min(mxx, x);
      if (d == 0) mny = max(mny, y);
      if (a == 0 or b == 0 or c == 0 or d == 0) pos = false;
    }
    if (pos == true) {
      cout << 1 << ' ' << mxx - 1 << ' ' << mxy - 1 << endl;
    } else if (mxx < mnx or mxy < mny)
      cout << 0 << endl;
    else {
      cout << 1 << ' ' << mnx << ' ' << mxy << endl;
    }
  }
}
