#include <bits/stdc++.h>
using namespace std;
int main() {
  long long m, n, x, y, f1, f2, f3, f4, zuo = 100000, you = -100000,
                                        xia = 100000, shang = -100000;
  scanf("%lld", &m);
  while (m--) {
    scanf("%lld", &n);
    zuo = 100000;
    you = -100000;
    xia = 100000;
    shang = -100000;
    while (n--) {
      scanf("%lld%lld%lld%lld%lld%lld", &x, &y, &f1, &f2, &f3, &f4);
      if (f1 == 0 && x > you) you = x;
      if (f3 == 0 && x < zuo) zuo = x;
      if (f2 == 0 && y < xia) xia = y;
      if (f4 == 0 && y > shang) shang = y;
    }
    if (shang <= xia && you <= zuo)
      printf("1 %lld %lld\n", you, shang);
    else
      printf("0\n");
  }
}
