#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int z = 100000;
    int l = -z, u = z, d = -z, r = z;
    int n;
    cin >> n;
    int x, y, a1, a2, a3, a4;
    for (int i = 0; i < n; i++) {
      cin >> x >> y >> a1 >> a2 >> a3 >> a4;
      if (a1 == 0) {
        l = max(l, x);
      }
      if (a2 == 0) {
        u = min(u, y);
      }
      if (a3 == 0) {
        r = min(r, x);
      }
      if (a4 == 0) {
        d = max(d, y);
      }
    }
    if (l <= r && d <= u) {
      cout << 1 << " " << l << " " << d << endl;
    } else {
      cout << 0 << endl;
    }
  }
}
