#include <bits/stdc++.h>
using namespace std;
int T, N, A[100010][6];
int U, D, L, R;
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &N);
    for (int i = 0; i < N; i++)
      for (int j = 0; j < 6; j++) scanf("%d", &A[i][j]);
    U = 100000;
    D = -100000;
    L = -100000;
    R = 100000;
    for (int i = 0; i < N; i++) {
      int X = A[i][0], Y = A[i][1];
      if (!A[i][3]) U = min(U, Y);
      if (!A[i][5]) D = max(D, Y);
      if (!A[i][4]) R = min(R, X);
      if (!A[i][2]) L = max(L, X);
    }
    if (D > U || L > R)
      printf("0\n");
    else
      printf("1 %d %d\n", L, D);
  }
  return 0;
}
