#include <bits/stdc++.h>
using namespace std;
long long int mod97 = 1000000007;
long long int modg = 998244353;
double pi = 3.1415926536;
bool comp(pair<long long int, long long int> a,
          pair<long long int, long long int> b) {
  if (a.first == b.first) {
    if (a.second <= b.second)
      return true;
    else
      return false;
  }
  if (a.first > b.first)
    return true;
  else
    return false;
}
bool rev(long long int a, long long int b) {
  if (a > b)
    return true;
  else
    return false;
}
bool compa(pair<string, pair<int, int>> a, pair<string, pair<int, int>> b) {
  if (a.first == b.first) {
    if (a.second.first > b.second.first)
      return true;
    else
      return false;
  }
  if (a.first < b.first)
    return true;
  else
    return false;
}
long long int gcd(long long int bdda, long long int chota) {
  if (chota == 0) return bdda;
  return gcd(chota, bdda % chota);
}
long long int lcm(long long int a, long long int b) {
  return a * b / gcd(max(a, b), min(a, b));
}
long long int powerm(long long int a, long long int n, long long int modn) {
  if (n == 0) return 1;
  if (n % 2 == 0) {
    long long int val = powerm(a, n / 2, modn);
    val = (val * val) % modn;
    return val;
  } else {
    long long int val = powerm(a, n / 2, modn);
    val = ((val * val) % modn * a) % modn;
    return val;
  }
}
long long int power(long long int a, long long int n) {
  if (n == 0) return 1;
  if (n % 2 == 0) {
    long long int val = power(a, n / 2);
    val = (val * val);
    return val;
  } else {
    long long int val = power(a, n / 2);
    val = ((val * val) * a);
    return val;
  }
}
bool comppp(string a, string b) {
  if (a.size() > b.size())
    return true;
  else
    return false;
}
bool compp(pair<long long int, long long int> a,
           pair<long long int, long long int> b) {
  if (a.second < b.second)
    return true;
  else if (a.second > b.second)
    return false;
  else {
    if (a.first < b.first)
      return true;
    else
      return false;
  }
}
void solve() {
  long long int n;
  cin >> n;
  vector<pair<long long int, long long int>> v(n);
  long long int a[n][4];
  for (long long int i = 0; i < n; i++) {
    cin >> v[i].first >> v[i].second >> a[i][0] >> a[i][1] >> a[i][2] >>
        a[i][3];
  }
  long long int xl = -100000, xu = 100000, yu = 100000, yl = -100000;
  for (long long int i = 0; i < n; i++) {
    long long int prox = 1, proy = 1;
    long long int vxl = -100000, vxu = 100000, vyl = -100000, vyu = 100000;
    if (xl <= v[i].first && xu >= v[i].first) {
      prox--;
    }
    if (yl <= v[i].second && yu >= v[i].second) {
      proy--;
    }
    if (a[i][0] == 0 && a[i][2] == 0 && prox == 1) {
      cout << 0 << endl;
      return;
    }
    if (prox == 1 && a[i][0] == 0 && xu < v[i].first) {
      cout << 0 << endl;
      return;
    }
    if (prox == 1 && a[i][2] == 0 && xl > v[i].first) {
      cout << 0 << endl;
      return;
    }
    if (a[i][1] == 0 && a[i][3] == 0 && proy == 1) {
      cout << 0 << endl;
      return;
    }
    if (proy == 1 && a[i][3] == 0 && yu < v[i].second) {
      cout << 0 << endl;
      return;
    }
    if (proy == 1 && a[i][1] == 0 && yl > v[i].second) {
      cout << 0 << endl;
      return;
    }
    if (a[i][0] == 0) xl = max(xl, v[i].first);
    if (a[i][2] == 0) xu = min(xu, v[i].first);
    if (a[i][1] == 0) yu = min(yu, v[i].second);
    if (a[i][3] == 0) yl = max(yl, v[i].second);
  }
  if (xl > xu || yl > yu) {
    cout << 0 << endl;
  } else {
    cout << 1 << " " << xl << " " << yl << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
