#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    int a = 100000, b = 100000, c = -100000, d = -100000;
    vector<bool> ok(4, false);
    for (int i = 0; i < n; i++) {
      int x, y;
      cin >> x >> y;
      int f[4];
      for (int j = 0; j < 4; j++) cin >> f[j];
      if (f[0] == 0) d = max(d, x), ok[0] = true;
      if (f[1] == 0) a = min(a, y), ok[1] = true;
      if (f[2] == 0) b = min(b, x), ok[2] = true;
      if (f[3] == 0) c = max(c, y), ok[3] = true;
    }
    if (a < c || d > b)
      cout << 0;
    else
      cout << 1 << ' ' << (d + b) / 2 << ' ' << (a + c) / 2;
    cout << endl;
  }
}
