#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int n, xmin = -100000, ymin = -100000, xmax = 100000,
                     ymax = 100000, i, q = 0, a, b, c, d, e, f;
    cin >> n;
    for (i = 0; i < n; i++) {
      cin >> a >> b >> c >> d >> e >> f;
      if (c == 0) {
        xmin = max(xmin, a);
      }
      if (d == 0) ymax = min(ymax, b);
      if (e == 0) xmax = min(xmax, a);
      if (f == 0) ymin = max(ymin, b);
    }
    if (xmin <= xmax && ymin <= ymax)
      cout << 1 << " " << xmin << " " << ymin << endl;
    else
      cout << 0 << endl;
  }
  return 0;
}
