import sys
from sys import stdin
tt = int(stdin.readline())
ANS = []
for loop in range(tt):
n = int(stdin.readline())
L = U = -10**5
R = D = 10**5
for i in range(n):
x,y,f1,f2,f3,f4 = map(int,stdin.readline().split())
if f1 == 0:
L = max(L,x)
if f3 == 0:
R = min(R,x)
if f4 == 0:
U = max(U,y)
if f2 == 0:
D = min(D,y)
if L > R or U > D:
ANS.append("0")
else:
ANS.append("1 " + str(L) + " " + str(U) )
print ("\n".join(ANS))
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
struct DSU {
int size;
int componentCount;
int* parent;
int* height;
DSU(int _size) {
size = _size;
componentCount = size;
parent = new int[size];
height = new int[size];
for (int i = 0; i < size; i++) {
parent[i] = i;
height[i] = 1;
}
}
int getRep(int a) {
int tmp = a;
while (parent[tmp] != tmp) {
tmp = parent[tmp];
}
parent[a] = tmp;
return tmp;
}
void connect(int a, int b) {
a = getRep(a), b = getRep(b);
if (a == b) return;
if (height[a] < height[b]) {
parent[a] = b;
}
else if (height[b] < height[a]) {
parent[b] = a;
}
else {
height[a]++;
parent[b] = a;
}
componentCount--;
}
};
long long binPow(long long x, long long y, long long mod) {
if (y == 0ll) return 1ll;
long long tmp = binPow(x, y / 2ll, mod);
if (y % 2ll == 0ll) return (tmp * tmp) % mod;
else return (((x * tmp) %mod) * tmp) % mod;
}
void solve() {
int n;
cin >> n;
//x y left up right down
vector<vector<int>> robots(n, vector<int>(6));
for (int i = 0; i < n; i++) {
for (int j = 0; j < 6; j++) {
cin >> robots[i][j];
}
}
int l = -100000, u = 100000, d = -100000, r = 100000;
for (int i = 0; i < n; i++) {
int _l = (robots[i][2] ? -100000 : robots[i][0]);
int _u = (robots[i][3] ? 100000 : robots[i][1]);
int _r = (robots[i][4] ? 100000 : robots[i][0]);
int _d = (robots[i][5] ? -100000 : robots[i][1]);
l = max(l, _l);
u = min(u, _u);
r = min(r, _r);
d = max(d, _d);
}
//cout << "*** ";
if (l > r || d > u) {
cout << "0\n";
return;
}
cout << "1 " << l << " " << u << "\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
bool unlimited = true;
if (unlimited) {
int t;
cin >> t;
while (t--) solve();
}
else {
solve();
}
return 0;
}
1408B - Arrays Sum | 1430A - Number of Apartments |
1475A - Odd Divisor | 1454B - Unique Bid Auction |
978C - Letters | 501B - Misha and Changing Handles |
1496A - Split it | 1666L - Labyrinth |
1294B - Collecting Packages | 1642B - Power Walking |
1424M - Ancient Language | 600C - Make Palindrome |
1669D - Colorful Stamp | 1669B - Triple |
1669A - Division | 1669H - Maximal AND |
1669E - 2-Letter Strings | 483A - Counterexample |
3C - Tic-tac-toe | 1669F - Eating Candies |
1323B - Count Subrectangles | 991C - Candies |
1463A - Dungeon | 1671D - Insert a Progression |
1671A - String Building | 1671B - Consecutive Points Segment |
1671C - Dolce Vita | 1669G - Fall Down |
4D - Mysterious Present | 1316B - String Modification |