#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, i, up, down, left, right, tx, ty, a, b, c, d;
  cin >> t;
  while (t--) {
    up = right = 100000;
    down = left = -100000;
    cin >> n;
    for (i = 1; i <= n; ++i) {
      cin >> tx >> ty >> a >> b >> c >> d;
      if (!a)
        if (tx > left) left = tx;
      if (!b)
        if (ty < up) up = ty;
      if (!c)
        if (tx < right) right = tx;
      if (!d)
        if (ty > down) down = ty;
    }
    if (right < left || up < down)
      cout << 0 << endl;
    else
      cout << 1 << " " << right << " " << up << endl;
  }
}
