#include <bits/stdc++.h>
using namespace std;
int q, n;
int mx = 100000;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> q;
  while (q--) {
    cin >> n;
    vector<vector<int> > robots(n, vector<int>(6));
    int leftbound = -mx;
    int rightbound = mx;
    int botbound = -mx;
    int topbound = mx;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < 6; j++) {
        cin >> robots[i][j];
      }
    }
    for (int i = 0; i < n; i++) {
      int x = robots[i][0];
      int y = robots[i][1];
      if (!robots[i][2]) {
        leftbound = max(leftbound, x);
      }
      if (!robots[i][3]) {
        topbound = min(topbound, y);
      }
      if (!robots[i][4]) {
        rightbound = min(rightbound, x);
      }
      if (!robots[i][5]) {
        botbound = max(botbound, y);
      }
    }
    if (botbound <= topbound && leftbound <= rightbound) {
      cout << "1 " << leftbound << " " << topbound << "\n";
    } else {
      cout << 0 << "\n";
    }
  }
}
