#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  while (q--) {
    int n, upper = 100000, right = 100000, left = -100000, down = -100000;
    cin >> n;
    while (n--) {
      int x, y, a, b, c, d;
      cin >> x >> y >> a >> b >> c >> d;
      if (!a) {
        left = max(left, x);
      }
      if (!b) {
        upper = min(upper, y);
      }
      if (!c) {
        right = min(right, x);
      }
      if (!d) {
        down = max(down, y);
      }
    }
    if (upper < down || right < left) {
      cout << 0 << endl;
    } else {
      cout << 1 << " ";
      cout << right << " " << down << endl;
    }
  }
  return 0;
}
