#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> v1, v2, v3, v4;
    for (long long i = 0; i < n; i++) {
      long long x, y, f1, f2, f3, f4;
      cin >> x >> y >> f1 >> f2 >> f3 >> f4;
      if (f1 == 0) v1.push_back(x);
      if (f2 == 0) v2.push_back(y);
      if (f3 == 0) v3.push_back(x);
      if (f4 == 0) v4.push_back(y);
    }
    v1.push_back(-100000);
    v2.push_back(100000);
    v3.push_back(100000);
    v4.push_back(-100000);
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());
    sort(v3.begin(), v3.end());
    sort(v4.begin(), v4.end());
    if (v1[v1.size() - 1] <= v3[0] and v2[0] >= v4[v4.size() - 1])
      cout << 1 << " " << (v1[v1.size() - 1] + v3[0]) / 2 << " "
           << (v2[0] + v4[v4.size() - 1]) / 2 << "\n";
    else
      cout << 0 << "\n";
  }
}
