#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int i, j;
  long long int n, k;
  int test;
  cin >> test;
  while (test--) {
    long long int n;
    cin >> n;
    vector<long long int> v[n + 5], va[n + 5], vb[n + 5];
    for (i = 1; i <= n; i++) {
      long long int count = 6, val;
      while (count > 0) {
        cin >> val;
        v[i].push_back(val);
        count--;
      }
      long long int x = v[i][0];
      long long int y = v[i][1];
      if (v[i][2] == 1)
        va[i].push_back(-100000);
      else
        va[i].push_back(x);
      if (v[i][5] == 1)
        vb[i].push_back(-100000);
      else
        vb[i].push_back(y);
      if (v[i][3] == 1)
        vb[i].push_back(100000);
      else
        vb[i].push_back(y);
      if (v[i][4] == 1)
        va[i].push_back(100000);
      else
        va[i].push_back(x);
    }
    long long int mx_cord = -100000, mn_cord = 100000;
    long long int y_val = 100000, x_val = -100000;
    for (i = 1; i <= n; i++) {
      mx_cord = max(va[i][0], mx_cord);
      mn_cord = min(mn_cord, va[i][1]);
      x_val = max(vb[i][0], x_val);
      y_val = min(y_val, vb[i][1]);
    }
    if (mx_cord > mn_cord || x_val > y_val)
      cout << 0 << "\n";
    else
      cout << 1 << " " << mn_cord << " " << x_val << "\n";
  }
  return 0;
}
