#include <bits/stdc++.h>
using namespace std;
constexpr int INF = 1e9;
constexpr int mx = 1e5;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int mix = -mx, mxx = mx;
    int miy = -mx, mxy = mx;
    while (n--) {
      int x, y, f1, f2, f3, f4;
      cin >> x >> y >> f1 >> f2 >> f3 >> f4;
      if (!f1) mix = max(mix, x);
      if (!f2) mxy = min(mxy, y);
      if (!f3) mxx = min(mxx, x);
      if (!f4) miy = max(miy, y);
    }
    if (mix <= mxx && miy <= mxy) {
      cout << "1 " << mix << " " << miy << endl;
    } else
      cout << 0 << endl;
  }
  return 0;
}
