#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  for (long long z = 0; z < t; z++) {
    long long n;
    cin >> n;
    long long x[n], y[n], f1[n], f2[n], f3[n], f4[n], x_mi, x_ma, y_mi, y_ma;
    for (long long i = 0; i < n; i++)
      cin >> x[i] >> y[i] >> f1[i] >> f2[i] >> f3[i] >> f4[i];
    x_mi = -100000;
    x_ma = 100000;
    y_mi = -100000;
    y_ma = 100000;
    for (long long i = 0; i < n; i++) {
      if (f1[i] == 0)
        if (x[i] >= x_mi) x_mi = x[i];
      if (f3[i] == 0)
        if (x[i] <= x_ma) x_ma = x[i];
      if (f4[i] == 0)
        if (y[i] >= y_mi) y_mi = y[i];
      if (f2[i] == 0)
        if (y[i] <= y_ma) y_ma = y[i];
    }
    if (x_mi <= x_ma && y_mi <= y_ma)
      cout << 1 << " " << x_mi << " " << y_mi << endl;
    else
      cout << 0 << endl;
  }
}
