#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
string char_to_str(char c) {
  string tem(1, c);
  return tem;
}
long long max(long long a, long long b) {
  if (a > b) {
    return a;
  }
  return b;
}
long long min(long long a, long long b) {
  if (a < b) {
    return a;
  }
  return b;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    int mix = -100000;
    int mx = 100000;
    int miy = -100000;
    int my = 100000;
    for (int i = 0; i < n; ++i) {
      int x, y;
      cin >> x >> y;
      int d;
      cin >> d;
      if (d == 0) {
        mix = max(mix, x);
      }
      cin >> d;
      if (d == 0) {
        my = min(my, y);
      }
      cin >> d;
      if (d == 0) {
        mx = min(mx, x);
      }
      cin >> d;
      if (d == 0) {
        miy = max(miy, y);
      }
    }
    if (mix > mx || miy > my) {
      cout << 0 << endl;
    } else {
      cout << "1 ";
      cout << mx << " " << my << endl;
    }
  }
  return 0;
}
