#include <bits/stdc++.h>
using namespace std;
template <class T>
inline istream& operator>>(istream& str, vector<T>& a) {
  for (auto& i : a) str >> i;
  return str;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int T, tc = 0;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    int xl = -1e5, xr = 1e5, yb = -1e5, yu = 1e5;
    for (int i = 0; i < n; ++i) {
      int x, y;
      cin >> x >> y;
      int f;
      cin >> f;
      if (f == 0) {
        xl = max(xl, x);
      }
      cin >> f;
      if (f == 0) {
        yu = min(yu, y);
      }
      cin >> f;
      if (f == 0) {
        xr = min(xr, x);
      }
      cin >> f;
      if (f == 0) {
        yb = max(yb, y);
      }
    }
    if (xl <= xr and yb <= yu) {
      cout << "1 " << xl << " " << yb << "\n";
    } else {
      cout << "0\n";
    }
  }
  return 0;
}
