#include <bits/stdc++.h>
using namespace std;
int t, n, x, y, a, b, c, d;
int maxx, maxy, minx, miny;
bool flag;
int main() {
  cin >> t;
  while (t--) {
    cin >> n;
    maxx = 100000, maxy = 100000;
    minx = -100000, miny = -100000;
    flag = false;
    for (int i = 1; i <= n; i++) {
      cin >> x >> y >> a >> b >> c >> d;
      if (a == 0) minx = max(x, minx);
      if (b == 0) maxy = min(y, maxy);
      if (c == 0) maxx = min(x, maxx);
      if (d == 0) miny = max(y, miny);
      if (minx > maxx || miny > maxy) {
        flag = true;
      }
    }
    if (flag)
      cout << "0" << endl;
    else
      cout << "1"
           << " " << minx << " " << miny << endl;
  }
  return 0;
}
