#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long mx = -1e5, Mx = 1e5, my = -1e5, My = 1e5;
    while (n--) {
      long long x, y, l, u, r, d;
      cin >> x >> y >> l >> u >> r >> d;
      if (l == 0) mx = max(mx, x);
      if (r == 0) Mx = min(Mx, x);
      if (u == 0) My = min(My, y);
      if (d == 0) my = max(my, y);
    }
    if (mx > Mx || my > My)
      cout << 0;
    else
      cout << 1 << ' ' << Mx << ' ' << My;
    cout << '\n';
  }
}
