#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void amin(T &x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
inline void amax(T &x, U y) {
  if (x < y) x = y;
}
void err(istream_iterator<string> it) { cerr << endl; }
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  if (1 == 0) return;
  cerr << *it << " = " << a << " ";
  err(++it, args...);
}
int main() {
  int TC;
  cin >> TC;
  while (TC--) {
    int ro;
    cin >> ro;
    bool pos = true;
    int top = 100000, bottom = -100000, left = -100000, right = 100000;
    while (ro--) {
      int x, y, l, d, r, u;
      cin >> x >> y >> l >> u >> r >> d;
      if (l == 0) left = max(left, x);
      if (r == 0) right = min(right, x);
      if (u == 0) top = min(top, y);
      if (d == 0) bottom = max(bottom, y);
    }
    if (left <= right && top >= bottom)
      cout << 1 << " " << left << " " << bottom << endl;
    else
      cout << 0 << endl;
  }
  return 0;
}
