#include <bits/stdc++.h>
using namespace std;
struct pt {
  int x, y;
  pt(int x, int y) : x(x), y(y) {}
};
int main() {
  int q, n, x, y, l, r, u, d;
  cin >> q;
  while (q--) {
    scanf("%d", &n);
    pt lu(-1e5, -1e5), ld(1e5, -1e5), ru(-1e5, 1e5), rd(1e5, 1e5);
    bool fl = false;
    for (int i = 1; i <= n; ++i) {
      scanf("%d%d%d%d%d%d", &x, &y, &u, &r, &d, &l);
      if (u == 0) {
        if (lu.x <= x) lu.x = x;
      }
      if (r == 0) {
        if (rd.y >= y) rd.y = y;
      }
      if (d == 0) {
        if (rd.x >= x) rd.x = x;
      }
      if (l == 0) {
        if (lu.y <= y) lu.y = y;
      }
    }
    if (lu.x > rd.x || lu.y > rd.y) fl = true;
    if (fl)
      cout << 0 << endl;
    else
      cout << 1 << " " << lu.x << " " << rd.y << endl;
  }
  return 0;
}
