#include <bits/stdc++.h>
using namespace std;
int main() {
  long long q;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int n;
    cin >> n;
    int minx = -100000;
    int miny = -100000;
    int maxy = 100000;
    int maxx = 100000;
    int x;
    for (int j = 0; j < n; ++j) {
      int x, y;
      cin >> x >> y;
      int op;
      cin >> op;
      if (!op) {
        minx = max(minx, x);
      }
      cin >> op;
      if (!op) {
        maxy = min(maxy, y);
      }
      cin >> op;
      if (!op) {
        maxx = min(maxx, x);
      }
      cin >> op;
      if (!op) {
        miny = max(miny, y);
      }
    }
    if ((maxx < minx) || (maxy < miny)) {
      cout << 0 << endl;
    } else {
      cout << 1 << " " << maxx << " " << maxy << endl;
    }
  }
}
