#include <bits/stdc++.h>
using namespace std;
int main() {
  int q, n, x, y, f1, f2, f3, f4;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    cin >> n;
    int minx = -100000, miny = -100000, maxx = 100000, maxy = 100000;
    for (int o = 0; o < n; ++o) {
      cin >> x >> y >> f1 >> f2 >> f3 >> f4;
      if (f1 == 0 && minx < x) {
        minx = x;
      }
      if (f2 == 0 && maxy > y) {
        maxy = y;
      }
      if (f3 == 0 && maxx > x) {
        maxx = x;
      }
      if (f4 == 0 && miny < y) {
        miny = y;
      }
    }
    if (minx > maxx || miny > maxy) {
      cout << 0 << endl;
    } else {
      cout << 1 << " " << minx << " " << miny << endl;
    }
  }
  cin >> n;
  return 0;
}
