#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100 * 1000 + 12;
int n, q;
int x, y;
bool f;
int main() {
  cin >> q;
  while (q--) {
    int lx = -100 * 1000, hx = 100 * 1000, ly = -100 * 1000, hy = 100 * 1000;
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> x >> y >> f;
      if (!f) lx = max(lx, x);
      cin >> f;
      if (!f) hy = min(hy, y);
      cin >> f;
      if (!f) hx = min(hx, x);
      cin >> f;
      if (!f) ly = max(ly, y);
    }
    if (hx - lx < 0 || hy - ly < 0)
      cout << 0 << '\n';
    else
      cout << 1 << ' ' << lx << ' ' << ly << '\n';
  }
  return 0;
}
