#include <bits/stdc++.h>
using namespace std;
const int le = 1e5;
const int lbound = -(1e5);
const int rbound = 1e5;
int boundlx, boundrx;
int boundly, boundry;
bool valx, valy;
struct robot {
 public:
  int x, y;
  bool fl, fr, ft, fb;
  robot(int x = 0, int y = 0, bool fl = 0, bool ft = 0, bool fr = 0,
        bool fb = 0) {
    this->x = x;
    this->y = y;
    this->fl = fl;
    this->fr = fr;
    this->ft = ft;
    this->fb = fb;
  }
};
robot rb[le];
bool bans[le];
pair<int, int> pans[le];
int cmp(const void* a, const void* b) {
  pair<int, int> left = *static_cast<const pair<int, int>*>(a);
  pair<int, int> right = *static_cast<const pair<int, int>*>(b);
  if (left.first != right.first) {
    return left.first - right.first;
  }
  return right.second - left.second;
}
void cutpr(int l1, int r1, int l2, int r2, int& l, int& r, bool& isvalid) {
  pair<int, int> scan[4];
  scan[0] = {l1, 1};
  scan[1] = {r1, 0};
  scan[2] = {l2, 1};
  scan[3] = {r2, 0};
  qsort(scan, 4, sizeof(pair<int, int>), cmp);
  int open = 0;
  for (int i = 0; i < 4; i++) {
    if (scan[i].second == 1) {
      open++;
    } else {
      if (open == 2) {
        l = scan[i - 1].first;
        r = scan[i].first;
        isvalid = true;
        return;
      } else {
        isvalid = false;
        return;
      }
    }
  }
  throw;
}
int main() {
  int q;
  cin >> q;
  for (int p = 0; p < q; p++) {
    boundlx = boundly = lbound;
    boundrx = boundry = rbound;
    valx = valy = true;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
      int x, y;
      bool b1, b2, b3, b4;
      cin >> x >> y >> b1 >> b2 >> b3 >> b4;
      rb[i] = robot(x, y, b1, b2, b3, b4);
      robot cur = rb[i];
      if (valx && valy) {
        int lx = cur.fl ? lbound : cur.x;
        int rx = cur.fr ? rbound : cur.x;
        int ly = cur.fb ? lbound : cur.y;
        int ry = cur.ft ? rbound : cur.y;
        cutpr(lx, rx, boundlx, boundrx, boundlx, boundrx, valx);
        cutpr(ly, ry, boundly, boundry, boundly, boundry, valy);
      }
    }
    if (valx && valy) {
      bans[p] = true;
      pans[p] = {boundlx, boundly};
    } else {
      bans[p] = false;
    }
  }
  for (int p = 0; p < q; p++) {
    if (bans[p]) {
      cout << 1 << ' ' << pans[p].first << ' ' << pans[p].second << endl;
    } else {
      cout << 0 << endl;
    }
  }
}
