#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const unsigned long long int MOD = 998244353;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int q, x, y, f1, f2, f3, f4, n, i, maxx, maxy, minx, miny;
  cin >> q;
  while (q--) {
    cin >> n;
    bool flag = true;
    maxx = 100000;
    maxy = 100000;
    minx = -100000;
    miny = -100000;
    for (i = 0; i < n; i++) {
      cin >> x >> y >> f1 >> f2 >> f3 >> f4;
      if (!f1) minx = max(x, minx);
      if (!f2) maxy = min(y, maxy);
      if (!f3) maxx = min(x, maxx);
      if (!f4) miny = max(y, miny);
    }
    if (minx <= maxx and miny <= maxy) {
      cout << 1 << " " << maxx << " " << maxy << '\n';
    } else {
      cout << 0 << '\n';
    }
  }
  return 0;
}
