#include <bits/stdc++.h>
using namespace std;
bool solve(int& X, int& Y) {
  int n;
  cin >> n;
  pair<int, int> stay = {INT_MAX, INT_MAX};
  int xmin = -1e5 - 1, xmax = 1e5 + 1, ymin = -1e5 - 1, ymax = 1e5 + 1;
  vector<vector<int>> ops;
  for (int i = 0; i < n; i++) {
    int x, y;
    int U, R, D, L;
    cin >> x >> y >> U >> R >> D >> L;
    ops.push_back({x, y, U, R, D, L});
  }
  for (int i = 0; i < n; i++) {
    int x = ops[i][0], y = ops[i][1], U = ops[i][2], R = ops[i][3],
        D = ops[i][4], L = ops[i][5];
    if (U + R + D + L == 4) continue;
    if (U + R + D + L == 0) {
      if (stay.first == INT_MAX && stay.second == INT_MAX) {
        stay.first = x;
        stay.second = y;
      } else if (stay.first != x || stay.second != y)
        return false;
    } else {
      if (U + R + D + L == 1) {
        if (U == 1) {
          if (y < ymin || y > ymax || x < xmin)
            return false;
          else
            ymin = ymax = y, xmax = min(x, xmax);
        } else if (R == 1) {
          if (x < xmin || x > xmax || y > ymax)
            return false;
          else
            xmin = xmax = x, ymin = max(y, ymin);
        } else if (D == 1) {
          if (y < ymin || y > ymax || x > xmax)
            return false;
          else
            ymin = ymax = y, xmin = max(x, xmin);
        } else {
          if (x < xmin || x > xmax || y < ymin)
            return false;
          else
            xmin = xmax = x, ymax = min(y, ymax);
        }
      } else if (U + R + D + L == 2) {
        if (U + R == 2) {
          if (x < xmin || y > ymax)
            return false;
          else
            xmax = min(x, xmax), ymin = max(y, ymin);
        } else if (U + D == 2) {
          if (y < ymin || y > ymax)
            return false;
          else
            ymin = ymax = y;
        } else if (U + L == 2) {
          if (x < xmin || y < ymin)
            return false;
          else
            xmax = min(x, xmax), ymax = min(y, ymax);
        } else if (R + D == 2) {
          if (y > ymax || x > xmax)
            return false;
          else
            ymin = max(y, ymin), xmin = max(x, xmin);
        } else if (R + L == 2) {
          if (x < xmin || x > xmax)
            return false;
          else
            xmin = xmax = x;
        } else if (D + L == 2) {
          if (x > xmax || y < ymin)
            return false;
          else
            xmin = max(x, xmin), ymax = min(y, ymax);
        }
      } else {
        if (U + R + D == 3) {
          if (y > ymax)
            return false;
          else
            ymin = max(y, ymin);
        } else if (U + R + L == 3) {
          if (x < xmin)
            return false;
          else
            xmax = min(x, xmax);
        } else if (R + D + L == 3) {
          if (x > xmax)
            return false;
          else
            xmin = max(x, xmin);
        } else {
          if (y < ymin)
            return false;
          else
            ymax = min(y, ymax);
        }
      }
    }
  }
  if (stay.first != INT_MAX && stay.first != INT_MAX)
    if (stay.first < xmin || stay.first > xmax || stay.second < ymin ||
        stay.second > ymax)
      return false;
  if (stay.first != INT_MAX && stay.first != INT_MAX)
    X = stay.first, Y = stay.second;
  else
    X = (xmin + xmax) / 2, Y = (ymin + ymax) / 2;
  return true;
}
int main() {
  int q;
  cin >> q;
  while (q--) {
    int X, Y;
    if (!solve(X, Y))
      cout << 0 << endl;
    else
      cout << 1 << " " << X << " " << Y << endl;
  }
}
