#include <bits/stdc++.h>
using namespace std;
void fast() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int main() {
  fast();
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    long long int x, y, s;
    long long int minx = -100000;
    long long int maxx = 100000;
    long long int miny = -100000;
    long long int maxy = 100000;
    for (long long int i = 0; i < n; i++) {
      cin >> x >> y;
      cin >> s;
      if (s == 0) {
        minx = max(minx, x);
      }
      cin >> s;
      if (s == 0) {
        maxy = min(maxy, y);
      }
      cin >> s;
      if (s == 0) {
        maxx = min(maxx, x);
      }
      cin >> s;
      if (s == 0) {
        miny = max(miny, y);
      }
    }
    if (minx <= maxx && miny <= maxy) {
      cout << "1 " << minx << " " << miny << endl;
    } else {
      cout << "0\n";
    }
  }
}
