#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  int left = -100000;
  int right = 100000;
  int up = 100000;
  int down = -100000;
  for (int i = 0; i < n; i++) {
    int x, y, left_dir, up_dir, right_dir, down_dir;
    cin >> x >> y >> left_dir >> up_dir >> right_dir >> down_dir;
    if (left_dir != 1) {
      left = max(x, left);
    }
    if (up_dir != 1) {
      up = min(up, y);
    }
    if (right_dir != 1) {
      right = min(right, x);
    }
    if (down_dir != 1) {
      down = max(down, y);
    }
  }
  if (left <= right && up >= down) {
    cout << "1 " << left << " " << up << endl;
    return;
  }
  cout << "0" << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
