#include <bits/stdc++.h>
using namespace std;
struct sss {
  int x, y, a, b, c, d, x1, y1, x2, y2;
  sss(int x, int y, int a, int b, int c, int d)
      : a(a), b(b), c(c), d(d), x(x), y(y) {
    if (a)
      x1 = -100000;
    else
      x1 = x;
    if (b)
      y1 = 100000;
    else
      y1 = y;
    if (c)
      x2 = 100000;
    else
      x2 = x;
    if (d)
      y2 = -100000;
    else
      y2 = y;
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  vector<sss> vv;
  long long q, n;
  int x, y, a, b, c, d, x1, y1, x2, y2;
  cin >> q;
  bool r = true;
  for (int i = 0; i < q; ++i) {
    cin >> n;
    for (int j = 0; j < n; ++j) {
      cin >> x >> y >> a >> b >> c >> d;
      vv.push_back(sss(x, y, a, b, c, d));
    }
    r = true;
    x1 = -100000;
    y1 = 100000;
    x2 = 100000;
    y2 = -100000;
    for (int j = 0; j < n; ++j) {
      if ((vv[j].x1 > x1)) {
        x1 = vv[j].x1;
      }
      if ((vv[j].x2 < x2)) {
        x2 = vv[j].x2;
      }
      if ((vv[j].y1 < y1)) {
        y1 = vv[j].y1;
      }
      if ((vv[j].y2 > y2)) {
        y2 = vv[j].y2;
      }
      if (x1 > x2 || y1 < y2) {
        r = false;
        break;
      }
    }
    if (!r) {
      cout << "0\n";
    } else {
      cout << "1 " << x1 << " " << y1 << endl;
    }
    vv.clear();
  }
  return 0;
}
