#include <bits/stdc++.h>
using namespace std;
int main(void) {
  unsigned t;
  scanf("%d", &t);
  while (t--) {
    int min_l = (100001);
    int max_r = -(100001);
    int max_u = -(100001);
    int min_d = (100001);
    int can_do = 1;
    uint32_t n = 0;
    scanf("%u", &n);
    while (n--) {
      int x, y;
      uint32_t l, u, r, d;
      scanf("%d%d%u%u%u%u", &x, &y, &l, &u, &r, &d);
      if (can_do) {
        if (!l) {
          if (min_l != (100001) && min_l < x) {
            can_do = 0;
          } else if (max_r < x) {
            max_r = x;
          }
        }
        if (!r) {
          if (max_r != -(100001) && max_r > x) {
            can_do = 0;
          } else if (min_l > x) {
            min_l = x;
          }
        }
        if (!d) {
          if (min_d != (100001) && min_d < y) {
            can_do = 0;
          } else if (max_u < y) {
            max_u = y;
          }
        }
        if (!u) {
          if (max_u != -(100001) && max_u > y) {
            can_do = 0;
          } else if (min_d > y) {
            min_d = y;
          }
        }
      }
    }
    if (can_do) {
      int cx = 0, cy = 0;
      if (min_l != (100001)) {
        cx = min_l;
      } else if (max_r != -(100001)) {
        cx = max_r;
      }
      if (min_d != (100001)) {
        cy = min_d;
      } else if (max_u != -(100001)) {
        cy = max_u;
      }
      printf("1 %d %d\n", cx, cy);
    } else {
      puts("0");
    }
  }
  return 0;
}
