#include <bits/stdc++.h>
using namespace std;
const int INF = 1e5;
int main() {
  int T;
  cin >> T;
  while (T--) {
    int N;
    cin >> N;
    int xMin = -INF, xMax = INF, yMin = -INF, yMax = INF;
    for (int i = 0; i < N; i++) {
      int X, Y, left, up, right, down;
      cin >> X >> Y >> left >> up >> right >> down;
      if (!left) xMin = max(xMin, X);
      if (!up) yMax = min(yMax, Y);
      if (!right) xMax = min(xMax, X);
      if (!down) yMin = max(yMin, Y);
    }
    if ((xMax - xMin) >= 0 && (yMax - yMin) >= 0) {
      cout << "1 " << xMin << " " << yMin;
    } else {
      cout << "0";
    }
    cout << "\n";
  }
  return 0;
}
