#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    int x, y, f, r, b, l, i;
    int x1 = 100000, x2 = -100000, y1 = 100000, y2 = -100000;
    bool flag = true;
    for (i = 0; i < n; i++) {
      cin >> x >> y;
      cin >> l >> f >> r >> b;
      if (r == 0) {
        x1 = min(x1, x);
        if (x1 < x2) {
          flag = false;
        }
      }
      if (f == 0) {
        y1 = min(y1, y);
        if (y1 < y2) {
          flag = false;
        }
      }
      if (l == 0) {
        x2 = max(x2, x);
        if (x1 < x2) {
          flag = false;
        }
      }
      if (b == 0) {
        y2 = max(y2, y);
        if (y1 < y2) {
          flag = false;
        }
      }
    }
    if (flag)
      cout << 1 << " " << x1 << " " << y1 << endl;
    else
      cout << 0 << endl;
  }
}
