#include <bits/stdc++.h>
using namespace std;
struct point {
  point(int a = 0, int b = 0) : x(a), y(b) {}
  int x, y;
};
int main() {
  int n;
  cin >> n;
  while (n--) {
    int m;
    cin >> m;
    int x, y, l, dow, r, u;
    scanf("%d%d%d%d%d%d", &x, &y, &l, &u, &r, &dow);
    int a = x, b = y, d = x, c = y;
    if (l) a = -1e5;
    if (r) d = 1e5;
    if (u) c = 1e5;
    if (dow) b = -1e5;
    int flag = 1;
    for (int i = 1; i <= m - 1; i++) {
      scanf("%d%d%d%d%d%d", &x, &y, &l, &u, &r, &dow);
      int a1 = x, b1 = y, d1 = x, c1 = y;
      if (l) a1 = -1e5;
      if (r) d1 = 1e5;
      if (u) c1 = 1e5;
      if (dow) b1 = -1e5;
      if (flag == 0) continue;
      if (a1 > d || d1 < a || b1 > c || c1 < b) {
        flag = 0;
        continue;
      }
      a = max(a, a1);
      b = max(b, b1);
      c = min(c, c1);
      d = min(d, d1);
    }
    if (flag == 1) {
      cout << 1 << ' ' << a << ' ' << b << '\n';
    } else
      cout << "0\n";
  }
}
