#include <bits/stdc++.h>
using namespace std;
bool f;
struct rect {
  int x1, x2, y1, y2;
  rect operator+(const rect &r) const {
    rect a;
    int x3 = r.x1, y3 = r.y1, x4 = r.x2, y4 = r.y2;
    int x5 = max(x1, x3);
    int y5 = max(y1, y3);
    int x6 = min(x2, x4);
    int y6 = min(y2, y4);
    if (x5 > x6 || y5 > y6) {
      f = 1;
      return a;
    }
    a.x1 = x5;
    a.y1 = y5;
    a.x2 = x6;
    a.y2 = y6;
    return a;
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  int N;
  cin >> N;
  for (; N--;) {
    f = 0;
    int n;
    rect r;
    r.x1 = r.y1 = -100000;
    r.x2 = r.y2 = 100000;
    cin >> n;
    for (int i = 0; i < n; i++) {
      int x, y, x1, x2, y1, y2;
      rect r1;
      bool a, b, c, d;
      cin >> x >> y >> a >> b >> c >> d;
      if (f) continue;
      if (a && b && c && d) continue;
      x1 = x2 = x;
      y1 = y2 = y;
      if (a) x1 = -100000;
      if (b) y2 = 100000;
      if (c) x2 = 100000;
      if (d) y1 = -100000;
      r1.x1 = x1;
      r1.x2 = x2;
      r1.y1 = y1;
      r1.y2 = y2;
      r = r + r1;
    }
    if (f)
      cout << 0 << endl;
    else {
      cout << 1 << " " << r.x1 << " " << r.y1 << endl;
    }
  }
  return 0;
}
