#include <bits/stdc++.h>
using namespace std;
struct Pt {
  long long int x, y, f1, f2, f3, f4;
};
bool cmp(Pt a1, Pt a2) { return a1.x < a2.x; }
int main() {
  long long int q, n;
  cin >> q;
  while (q--) {
    long long int X_left = INT_MIN, X_right = INT_MAX;
    long long int Y_bottom = INT_MIN, Y_top = INT_MAX;
    cin >> n;
    Pt arr[n];
    for (long long int i = 0; i < n; i++)
      cin >> arr[i].x >> arr[i].y >> arr[i].f1 >> arr[i].f2 >> arr[i].f3 >>
          arr[i].f4;
    sort(arr, arr + n, cmp);
    bool ans = true;
    for (long long int i = 0; i < n; i++) {
      if (arr[i].f1 == 1 && arr[i].f2 == 1 && arr[i].f3 == 1 && arr[i].f4 == 1)
        continue;
      if (arr[i].x > X_right) {
        if (arr[i].f1 == 1)
          arr[i].x = X_right;
        else {
          ans = false;
          goto t1;
        }
      }
      if (arr[i].y > Y_top) {
        if (arr[i].f4 == 1)
          arr[i].y = Y_top;
        else {
          ans = false;
          goto t1;
        }
      }
      if (arr[i].y < Y_bottom) {
        if (arr[i].f2 == 1)
          arr[i].y = Y_bottom;
        else {
          ans = false;
          goto t1;
        }
      }
      if (arr[i].f1 == 0) X_left = max(X_left, arr[i].x);
      if (arr[i].f2 == 0) Y_top = min(Y_top, arr[i].y);
      if (arr[i].f3 == 0) X_right = min(X_right, arr[i].x);
      if (arr[i].f4 == 0) Y_bottom = max(Y_bottom, arr[i].y);
    }
  t1:
    if (!ans) {
      cout << "0\n";
    } else {
      cout << "1 ";
      if (X_right != INT_MAX)
        cout << X_right << " ";
      else if (X_left != INT_MIN)
        cout << X_left << " ";
      else
        cout << arr[0].x << " ";
      if (Y_bottom != INT_MIN)
        cout << Y_bottom << " ";
      else if (Y_top != INT_MAX)
        cout << Y_top << " ";
      else
        cout << arr[0].y << " ";
      cout << "\n";
    }
  }
}
