#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    x = x * 10 + ch - '0', ch = getchar();
  }
  return f * x;
}
int t, n, x1, x2, yy1, yy2, nx, ny, f;
int main() {
  t = read();
  while (t--) {
    x1 = 100005, x2 = -100005, yy1 = 100005, yy2 = -100005;
    n = read();
    for (register int i = 1; i <= n; i++) {
      nx = read(), ny = read();
      f = read();
      if (!f) x2 = max(x2, nx);
      f = read();
      if (!f) yy1 = min(yy1, ny);
      f = read();
      if (!f) x1 = min(x1, nx);
      f = read();
      if (!f) yy2 = max(yy2, ny);
    }
    if (x1 >= x2 && yy1 >= yy2)
      printf("1 %d %d\n", min(x1, 100000), min(yy1, 100000));
    else
      printf("0\n");
  }
}
