#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t, n;
  cin >> t;
  while (t--) {
    cin >> n;
    long long lx = -100000, rx = 100000, ly = -100000, ry = 100000;
    while (n--) {
      long long x, y, L, R, U, D;
      cin >> x >> y;
      cin >> L >> U >> R >> D;
      if (!L) lx = max(lx, x);
      if (!R) rx = min(rx, x);
      if (!U) ry = min(ry, y);
      if (!D) ly = max(ly, y);
    }
    if (lx > rx || ly > ry)
      cout << 0 << "\n";
    else
      cout << 1 << " " << lx << " " << ly << "\n";
  }
  return 0;
}
