#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    int arr[n][6];
    for (int i = 0; i < n; i++) {
      cin >> arr[i][0] >> arr[i][1] >> arr[i][2] >> arr[i][3] >> arr[i][4] >>
          arr[i][5];
    }
    int maxx = 100000, minx = -100000, maxy = 100000, miny = -100000;
    for (int i = 0; i < n; i++) {
      if (arr[i][2] == 0) {
        minx = max(arr[i][0], minx);
      }
      if (arr[i][3] == 0) {
        maxy = min(maxy, arr[i][1]);
      }
      if (arr[i][4] == 0) {
        maxx = min(maxx, arr[i][0]);
      }
      if (arr[i][5] == 0) {
        miny = max(miny, arr[i][1]);
      }
    }
    if (maxx < minx || maxy < miny) {
      cout << 0 << endl;
    } else {
      cout << 1 << " " << minx << " " << miny << endl;
    }
  }
  return 0;
}
