#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int inf = 100000;
const long long INF = 1e18 + 3;
const long double eps = 1e-9;
const long double PI = acos(-1.0);
const long double E = 2.71828182845904523536;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int q, n;
  long long x, y, u, r, d, l;
  long long ansx, ansy, minx, miny, maxx, maxy;
  cin >> q;
  while (q--) {
    maxx = maxy = inf;
    minx = miny = -inf;
    cin >> n;
    for (int i = 0; i < (n); i++) {
      cin >> x >> y;
      cin >> u >> r >> d >> l;
      if (!u) minx = max(minx, x);
      if (!d) maxx = min(maxx, x);
      if (!l) miny = max(miny, y);
      if (!r) maxy = min(maxy, y);
    }
    if (minx > maxx || miny > maxy)
      cout << "0" << endl;
    else
      cout << "1 " << minx << " " << miny << endl;
  }
  return 0;
}
