#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t, lei, rii, upi, uni, le, ri, up, un, x, y;
  for (cin >> t; t; t--) {
    up = 100000;
    un = -100000;
    le = -100000;
    ri = 100000;
    for (cin >> n; n; n--) {
      cin >> x >> y >> lei >> upi >> rii >> uni;
      if (lei == 0) le = max(le, x);
      if (rii == 0) ri = min(ri, x);
      if (upi == 0) up = min(up, y);
      if (uni == 0) un = max(un, y);
    }
    if (le > ri || up < un)
      cout << "0" << endl;
    else
      cout << 1 << " " << le << " " << up << endl;
  }
}
