#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int qq;
  cin >> qq;
  for (int tt = 1; tt <= qq; tt++) {
    int n;
    cin >> n;
    long long xl = -(long long)1e5;
    long long xr = (long long)1e5;
    long long yl = -(long long)1e5;
    long long yr = (long long)1e5;
    long long cx, cy;
    int f0, f1, f2, f3;
    for (int i = 0; i < n; i++) {
      cin >> cx >> cy >> f0 >> f1 >> f2 >> f3;
      if (f0 == 0) xl = max(xl, cx);
      if (f1 == 0) yr = min(yr, cy);
      if (f2 == 0) xr = min(xr, cx);
      if (f3 == 0) yl = max(yl, cy);
    }
    if (xl <= xr && yl <= yr)
      cout << "1 " << xl << " " << yl << "\n";
    else
      cout << "0\n";
  }
  return 0;
}
