$n$ robots have escaped from your laboratory! You have to find them as soon as possible, because these robots are experimental, and their behavior is not tested yet, so they may be really dangerous!

Fortunately, even though your robots have escaped, you still have some control over them. First of all, you know the location of each robot: the world you live in can be modeled as an infinite coordinate plane, and the $i$-th robot is currently located at the point having coordinates ($x_i$, $y_i$). Furthermore, you may send exactly one command to all of the robots. The command should contain two integer numbers $X$ and $Y$, and when each robot receives this command, it starts moving towards the point having coordinates ($X$, $Y$). The robot stops its movement in two cases:  either it reaches ($X$, $Y$);  or it cannot get any closer to ($X$, $Y$). 

Normally, all robots should be able to get from any point of the coordinate plane to any other point. Each robot usually can perform four actions to move. Let's denote the current coordinates of the robot as ($x_c$, $y_c$). Then the movement system allows it to move to any of the four adjacent points:  the first action allows it to move from ($x_c$, $y_c$) to ($x_c - 1$, $y_c$);  the second action allows it to move from ($x_c$, $y_c$) to ($x_c$, $y_c + 1$);  the third action allows it to move from ($x_c$, $y_c$) to ($x_c + 1$, $y_c$);  the fourth action allows it to move from ($x_c$, $y_c$) to ($x_c$, $y_c - 1$). 

Unfortunately, it seems that some movement systems of some robots are malfunctioning. For each robot you know which actions it can perform, and which it cannot perform.

You want to send a command so all robots gather at the same point. To do so, you have to choose a pair of integer numbers $X$ and $Y$ so that each robot can reach the point ($X$, $Y$). Is it possible to find such a point?


-----Input-----

The first line contains one integer $q$ ($1 \le q \le 10^5$) — the number of queries.

Then $q$ queries follow. Each query begins with one line containing one integer $n$ ($1 \le n \le 10^5$) — the number of robots in the query. Then $n$ lines follow, the $i$-th of these lines describes the $i$-th robot in the current query: it contains six integer numbers $x_i$, $y_i$, $f_{i, 1}$, $f_{i, 2}$, $f_{i, 3}$ and $f_{i, 4}$ ($-10^5 \le x_i, y_i \le 10^5$, $0 \le f_{i, j} \le 1$). The first two numbers describe the initial location of the $i$-th robot, and the following four numbers describe which actions the $i$-th robot can use to move ($f_{i, j} = 1$ if the $i$-th robot can use the $j$-th action, and $f_{i, j} = 0$ if it cannot use the $j$-th action).

It is guaranteed that the total number of robots over all queries does not exceed $10^5$.


-----Output-----

You should answer each query independently, in the order these queries appear in the input.

To answer a query, you should do one of the following:  if it is impossible to find a point that is reachable by all $n$ robots, print one number $0$ on a separate line;  if it is possible to find a point that is reachable by all $n$ robots, print three space-separated integers on the same line: $1$ $X$ $Y$, where $X$ and $Y$ are the coordinates of the point reachable by all $n$ robots. Both $X$ and $Y$ should not exceed $10^5$ by absolute value; it is guaranteed that if there exists at least one point reachable by all robots, then at least one of such points has both coordinates not exceeding $10^5$ by absolute value.


-----Example-----
Input
4
2
-1 -2 0 0 0 0
-1 -2 0 0 0 0
3
1 5 1 1 1 1
2 5 0 1 0 1
3 5 1 0 0 0
2
1337 1337 0 1 1 1
1336 1337 1 1 0 1
1
3 5 1 1 1 1

Output
1 -1 -2
1 2 5
0
1 -100000 -100000

Difficulty: MEDIUM

Solutions:
T = int(input())
t = 0
for t in range(T):
	N = int(input())
	n = 0
	x1 = -100000
	x2 = 100000
	y1 = -100000
	y2 = 100000
	for n in range(N):
		(x, y, s, a, d, b) = map(int, input().split())
		if s == 0:
			x1 = max(x1, x)
		if a == 0:
			y2 = min(y2, y)
		if d == 0:
			x2 = min(x2, x)
		if b == 0:
			y1 = max(y1, y)
	if x1 <= x2 and y1 <= y2:
		print('1' + ' ' + str(x1) + ' ' + str(y1))
	else:
		print('0')
		n = n + 1
	t = t + 1


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	b = []
	for i in range(n):
		a = [int(x) for x in input().split()]
		b.append(a)
	L = []
	R = []
	U = []
	D = []
	for a in b:
		if a[2] == 0:
			L.append(a[0])
		if a[3] == 0:
			D.append(a[1])
		if a[4] == 0:
			R.append(a[0])
		if a[5] == 0:
			U.append(a[1])
	L.sort(reverse=True)
	R.sort()
	U.sort(reverse=True)
	D.sort()
	if len(L) == 0:
		L.insert(0, -100000)
	if len(U) == 0:
		U.insert(0, -100000)
	if len(R) == 0:
		R.insert(0, 100000)
	if len(D) == 0:
		D.insert(0, 100000)
	if L[0] > R[0] or U[0] > D[0]:
		print(0)
		continue
	print(1, L[0], U[0])


import sys
inf = sys.stdin
lines = inf.readlines()
linecounter = 0
q = int(lines[linecounter])
linecounter += 1
for tests in range(q):
	n = int(lines[linecounter])
	linecounter += 1
	x1 = -10 ** 5
	y1 = -10 ** 5
	x2 = 10 ** 5
	y2 = 10 ** 5
	for r in range(n):
		(x, y, f1, f2, f3, f4) = (int(val) for val in lines[linecounter].split())
		linecounter += 1
		if f1 == 0:
			x1 = max(x, x1)
		if f2 == 0:
			y2 = min(y, y2)
		if f3 == 0:
			x2 = min(x, x2)
		if f4 == 0:
			y1 = max(y, y1)
	if x1 <= x2 and y1 <= y2:
		print(1, x1, y1)
	else:
		print(0)


l = -10 ** 5
r = -l
u = r
b = l

def analyse(ar, R):
	x = ar[0]
	y = ar[1]
	f1 = ar[2]
	f2 = ar[3]
	f3 = ar[4]
	f4 = ar[5]
	if f1 == 1:
		R1x = [l, x]
	else:
		R1x = [x, x]
	if f2 == 1:
		L2y = [y, u]
	else:
		L2y = [y, y]
	if f3 == 1:
		R3x = [x, r]
	else:
		R3x = [x, x]
	if f4 == 1:
		L4y = [b, y]
	else:
		L4y = [y, y]
	Rx = [R1x[0], R3x[1]]
	Ly = [L4y[0], L2y[1]]
	if Rx[0] > R[0][1] or Rx[1] < R[0][0]:
		return 0
	elif Ly[0] > R[1][1] or Ly[1] < R[1][0]:
		return 0
	else:
		R = [[max(R[0][0], Rx[0]), min(R[0][1], Rx[1])], [max(R[1][0], Ly[0]), min(R[1][1], Ly[1])]]
	return R
queries = int(input())
for _ in range(queries):
	redundant = 0
	check = 1
	no_robots = int(input())
	robot_arr = [0] * no_robots
	R = [[l, r], [b, u]]
	for i in range(no_robots):
		robot_details = list(map(int, input().split(' ')))
		R = analyse(robot_details, R)
		if R == 0:
			check = 0
			for j in range(no_robots - i - 1):
				redundant = input()
			break
	if check == 0:
		print(0)
	else:
		print(1, R[0][0], R[1][0])


import atexit
import io
import sys
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
MAXC = int(100000.0)
t = int(input())
for i in range(t):
	(maxx, maxy, minx, miny) = (MAXC, MAXC, -MAXC, -MAXC)
	for q in range(int(input())):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		if not f1:
			minx = max(minx, x)
		if not f2:
			maxy = min(maxy, y)
		if not f3:
			maxx = min(maxx, x)
		if not f4:
			miny = max(miny, y)
	if minx <= maxx and miny <= maxy:
		print(1, minx, miny)
	else:
		print('0')


for i in range(int(input())):
	q = int(input())
	max_x = 100000
	max_y = 100000
	min_x = -100000
	min_y = -100000
	tt = 0
	for j in range(q):
		(x, y, l, u, r, d) = map(int, input().split())
		if l == 0:
			if max_x >= x:
				min_x = max(x, min_x)
			else:
				tt = 1
		if r == 0:
			if min_x <= x:
				max_x = min(max_x, x)
			else:
				tt = 1
		if d == 0:
			if max_y >= y:
				min_y = max(y, min_y)
			else:
				tt = 1
		if u == 0:
			if min_y <= y:
				max_y = min(y, max_y)
			else:
				tt = 1
	if min_x <= max_x and min_y <= max_y and (tt != 1):
		print(1, min_x, min_y)
	else:
		print(0)


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify, _heapify_max, _heappop_max

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(ri()):
		n = ri()
		initialrangex = [-100000, 100000]
		initialrangey = [-100000, 100000]
		ans = 1
		for i in range(n):
			(x, y, l, u, r, d) = ria()
			c = 0
			currrangex = [-100000, 100000]
			currrangey = [-100000, 100000]
			if l == 0:
				if r == 0:
					currrangex = [x, x]
				else:
					currrangex = [x, 100000]
			elif r == 0:
				currrangex = [-100000, x]
			if d == 0:
				if u == 0:
					currrangey = [y, y]
				else:
					currrangey = [y, 100000]
			elif u == 0:
				currrangey = [-100000, y]
			if currrangex[0] > initialrangex[1] or currrangex[1] < initialrangex[0]:
				c = 1
				ans = 0
			else:
				initialrangex[0] = max(initialrangex[0], currrangex[0])
				initialrangex[1] = min(initialrangex[1], currrangex[1])
			if currrangey[0] > initialrangey[1] or currrangey[1] < initialrangey[0]:
				c = 1
				ans = 0
			else:
				initialrangey[0] = max(initialrangey[0], currrangey[0])
				initialrangey[1] = min(initialrangey[1], currrangey[1])
		if ans:
			print(ans, initialrangex[0], initialrangey[0])
		else:
			print(ans)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


import sys
t = int(input())
for i in range(t):
	n = int(input())
	p = []
	for k in range(n):
		(x, y, s, a, d, b) = map(int, input().split())
		p.append([x, y, s, a, d, b])
	LD = 100000
	LS = -100000
	LA = 100000
	LB = -100000
	V = 1
	for k in range(n):
		if p[k][2] == 0:
			if p[k][0] >= LS and p[k][0] <= LD:
				LS = p[k][0]
			else:
				if p[k][0] < LS:
					if p[k][4] == 0:
						V = 0
				if p[k][0] > LD:
					V = 0
		if p[k][4] == 0:
			if p[k][0] <= LD and p[k][0] >= LS:
				LD = p[k][0]
			else:
				if p[k][0] > LD:
					if p[k][2] == 0:
						V = 0
				if p[k][0] < LS:
					V = 0
		if p[k][3] == 0:
			if p[k][1] <= LA and p[k][1] >= LB:
				LA = p[k][1]
			else:
				if p[k][1] > LA:
					if p[k][5] == 0:
						V = 0
				if p[k][1] < LA:
					V = 0
		if p[k][5] == 0:
			if p[k][1] >= LB and p[k][1] <= LA:
				LB = p[k][1]
			else:
				if LB > p[k][1]:
					if p[k][3] == 0:
						V = 0
				if LA < p[k][1]:
					V = 0
	if V == 0:
		print(0)
	else:
		print(1, end=' ')
		if LD == LS:
			print(LD, end=' ')
		elif LD < LS:
			print(LD, end=' ')
		else:
			print(LS, end=' ')
		if LA == LB:
			print(LA)
		elif LA < LB:
			print(LA)
		else:
			print(LB)


import sys
input = lambda : sys.stdin.readline().strip()
T = int(input())
for _ in range(T):
	n = int(input())
	minx = -10 ** 5
	maxx = 10 ** 5
	miny = -10 ** 5
	maxy = 10 ** 5
	for i in range(n):
		(x, y, f1, f2, f3, f4) = list(map(int, input().split()))
		if f1 == 0:
			minx = max(minx, x)
		if f2 == 0:
			maxy = min(maxy, y)
		if f3 == 0:
			maxx = min(maxx, x)
		if f4 == 0:
			miny = max(miny, y)
	if minx > maxx or miny > maxy:
		print(0)
	else:
		print(1, minx, miny)


q = int(input())
for _ in range(q):
	n = int(input())
	lm = dm = -100000
	rm = um = 100000
	for _ in range(n):
		(x, y, l, u, r, d) = list(map(int, input().split()))
		if l == 0:
			lm = max(lm, x)
		if r == 0:
			rm = min(rm, x)
		if u == 0:
			um = min(um, y)
		if d == 0:
			dm = max(dm, y)
	if lm > rm or um < dm:
		print(0)
	else:
		print(1, lm, dm)


from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	matrix = []
	(mi_x, mi_y) = (1000000, 1000000)
	(ma_x, ma_y) = (-1000000, -1000000)
	for i in range(n):
		matrix.append([int(i) for i in input().split()])
	u_x = u_y = 100000
	l_x = l_y = -100000
	for i in range(n):
		(x, y, dx, iy, ix, dy) = matrix[i]
		if ix == 0:
			u_x = min(x, u_x)
		if dx == 0:
			l_x = max(x, l_x)
		if iy == 0:
			u_y = min(y, u_y)
		if dy == 0:
			l_y = max(y, l_y)
	if u_x < l_x or u_y < l_y:
		print(0)
	else:
		print(1, l_x, l_y)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
for i in range(t):
	n = int(input())
	l = []
	for j in range(n):
		l.append(list(map(int, input().split())))
	(x1, y1, x2, y2) = (-10 ** 5, -10 ** 5, 10 ** 5, 10 ** 5)
	for j in l:
		if j[2] == 0:
			x1 = max(x1, j[0])
		if j[3] == 0:
			y2 = min(y2, j[1])
		if j[4] == 0:
			x2 = min(x2, j[0])
		if j[5] == 0:
			y1 = max(y1, j[1])
	if x1 > x2 or y1 > y2:
		print(0)
	else:
		print(1, x1, y1)


q = int(input())
for each in range(q):
	n = int(input())
	ans1_x = -100000
	ans1_y = -100000
	ans2_x = 100000
	ans2_y = 100000
	ans = 0
	for index in range(n):
		data = input().split(' ')
		x = int(data[0])
		y = int(data[1])
		if ans == 0:
			if int(data[2]) == 0:
				ans1_x = max(ans1_x, x)
			if int(data[4]) == 0:
				ans2_x = min(ans2_x, x)
			if int(data[3]) == 0:
				ans2_y = min(ans2_y, y)
			if int(data[5]) == 0:
				ans1_y = max(ans1_y, y)
			if ans1_x > ans2_x:
				ans = -1
			if ans1_y > ans2_y:
				ans = -1
	if ans == -1:
		print(0)
	else:
		print('1 %d %d' % (ans1_x, ans1_y))


from sys import stdin, stdout
riga = stdin.readline()
query = int(riga)
for i in range(query):
	riga = stdin.readline()
	n = int(riga)
	possibile = True
	minX = -100000
	minY = -100000
	maxX = 100000
	maxY = 100000
	j = 0
	while j != n:
		riga = stdin.readline()
		test = riga.split()
		(x, y, xLeft, yUp, xRight, yDown) = [int(value) for value in test]
		if xLeft == 0:
			if maxX < x:
				possibile = False
			else:
				minX = max(minX, x)
		if yUp == 0:
			if minY > y:
				possibile = False
			else:
				maxY = min(maxY, y)
		if xRight == 0:
			if minX > x:
				possibile = False
			else:
				maxX = min(maxX, x)
		if yDown == 0:
			if maxY < y:
				possibile = False
			else:
				minY = max(minY, y)
		j = j + 1
	if possibile:
		stdout.write('1 ' + str(minX) + ' ' + str(minY) + '\n')
	else:
		stdout.write('0\n')


for case in range(int(input())):
	(minx, maxx, miny, maxy) = [-100000, 100000, -100000, +100000]
	for r in range(int(input())):
		(x, y, f1, f2, f3, f4) = [int(x) for x in input().split()]
		minx = max(minx, x) if f1 == 0 else minx
		maxy = min(maxy, y) if f2 == 0 else maxy
		maxx = min(maxx, x) if f3 == 0 else maxx
		miny = max(miny, y) if f4 == 0 else miny
	if minx <= maxx and miny <= maxy:
		print(1, minx, miny)
	else:
		print(0)


from sys import stdin, stdout, exit
inf = 10 ** 5
q = int(input())
for it in range(q):
	n = int(stdin.readline())
	lb_x = -inf
	ub_x = inf
	lb_y = -inf
	ub_y = inf
	for i in range(n):
		(x, y, w, n, e, s) = map(int, stdin.readline().split())
		if not w:
			lb_x = max(lb_x, x)
		if not n:
			ub_y = min(ub_y, y)
		if not e:
			ub_x = min(ub_x, x)
		if not s:
			lb_y = max(lb_y, y)
	if lb_x <= ub_x and lb_y <= ub_y:
		stdout.write('1 ' + str(lb_x) + ' ' + str(lb_y) + '\n')
	else:
		stdout.write('0\n')


for _ in range(int(input())):
	n = int(input())
	xt = 10 ** 5
	xb = -10 ** 5
	yt = 10 ** 5
	yb = -10 ** 5
	possible = 1
	for i in range(n):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		if f1 == 0:
			if xt < x:
				possible = 0
			xb = max(xb, x)
		if f2 == 0:
			if yb > y:
				possible = 0
			yt = min(yt, y)
		if f3 == 0:
			if xb > x:
				possible = 0
			xt = min(x, xt)
		if f4 == 0:
			if yt < y:
				possible = 0
			yb = max(yb, y)
	if possible == 0:
		print(0)
	else:
		print(1, xb, yb)


def solve():
	n = int(input())
	(mix, mxx) = (-100000, 100000)
	(miy, mxy) = (-100000, 100000)
	for _i in range(n):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		if f1 == 0:
			mix = max(mix, x)
		if f2 == 0:
			mxy = min(mxy, y)
		if f3 == 0:
			mxx = min(mxx, x)
		if f4 == 0:
			miy = max(miy, y)
	if mix <= mxx and miy <= mxy:
		print(1, mix, miy)
	else:
		print(0)

def main():
	_ = int(input())
	while _:
		solve()
		_ -= 1
main()


for _ in range(int(input())):
	n = int(input())
	(maxx, minx) = (100000, -100000)
	(maxy, miny) = (100000, -100000)
	for _ in range(n):
		(xi, yi, d, r, u, l) = tuple(map(int, input().split()))
		if d == 0:
			minx = xi if xi > minx else minx
		if r == 0:
			maxy = yi if yi < maxy else maxy
		if u == 0:
			maxx = xi if xi < maxx else maxx
		if l == 0:
			miny = yi if yi > miny else miny
	if miny <= maxy and minx <= maxx:
		print(1, minx, miny)
	else:
		print(0)


import math
import sys
import collections

def getdict(n):
	d = {}
	if type(n) is list:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))
t = ii()
for i in range(t):
	n = ii()
	xmin = ymin = -10 ** 5
	xmax = ymax = 10 ** 5
	f = True
	for i in range(n):
		(x, y, l, u, r, d) = mi()
		if l == 0:
			xmin = max(x, xmin)
		if r == 0:
			xmax = min(xmax, x)
		if d == 0:
			ymin = max(y, ymin)
		if u == 0:
			ymax = min(ymax, y)
		if xmin > xmax or ymin > ymax:
			f = False
			continue
	print(f'1 {xmin} {ymin}') if f else print(0)


q = int(input())
for _ in range(q):
	n = int(input())
	robot = [[int(j) for j in input().split()] for i in range(n)]
	(min_x, min_y, max_x, max_y) = (-100000, -100000, 100000, 100000)
	for i in range(n):
		if robot[i][2] == 0:
			min_x = max([min_x, robot[i][0]])
		if robot[i][3] == 0:
			max_y = min([max_y, robot[i][1]])
		if robot[i][4] == 0:
			max_x = min([max_x, robot[i][0]])
		if robot[i][5] == 0:
			min_y = max([min_y, robot[i][1]])
	if min_x <= max_x and min_y <= max_y:
		print(' '.join([str(1), str(min_x), str(min_y)]))
	else:
		print(0)


a = int(input())
for i in range(a):
	d = []
	b = int(input())
	for j in range(b):
		d.append(list(map(int, input().split())))
	mix = -100000
	miy = mix
	maxx = 100000
	maxy = maxx
	f = True
	for j in range(b):
		x = d[j][0]
		y = d[j][1]
		if d[j][2] == 0:
			if x > maxx:
				print(0)
				f = False
				break
			mix = max(mix, x)
		if d[j][3] == 0:
			if y < miy:
				print(0)
				f = False
				break
			maxy = min(maxy, y)
		if d[j][5] == 0:
			if y > maxy:
				print(0)
				f = False
				break
			miy = max(miy, y)
		if d[j][4] == 0:
			if x < mix:
				print(0)
				f = False
				break
			maxx = min(maxx, x)
	if f:
		print(1, mix, miy)


import sys
input = sys.stdin.readline
Q = int(input())
for _ in range(Q):
	N = int(input())
	(minx, miny, maxx, maxy) = (-10 ** 5, -10 ** 5, 10 ** 5, 10 ** 5)
	for __ in range(N):
		(X, Y, L, U, R, D) = map(int, input().split())
		if L == 0:
			minx = max(minx, X)
		if R == 0:
			maxx = min(maxx, X)
		if U == 0:
			maxy = min(maxy, Y)
		if D == 0:
			miny = max(miny, Y)
	if maxx >= minx and maxy >= miny:
		print(1, minx, miny)
	else:
		print(0)


q = int(input())
for i in range(q):
	n = int(input())
	b = []
	x = []
	y = []
	for j in range(n):
		a = list(map(int, input().split(' ')))
		b.append(a)
		x.append(a[0])
		y.append(a[1])
	x_range = [-10 ** 5, 10 ** 5]
	y_range = [-10 ** 5, 10 ** 5]
	for i in range(n):
		if x_range[0] > x_range[1] or y_range[0] > y_range[1]:
			print(0)
			break
		if b[i][2] == 1:
			if b[i][4] == 0:
				if x[i] < x_range[1]:
					x_range[1] = x[i]
		elif b[i][4] == 1:
			if x[i] > x_range[0]:
				x_range[0] = x[i]
		else:
			if x[i] < x_range[1]:
				x_range[1] = x[i]
			if x[i] > x_range[0]:
				x_range[0] = x[i]
		if b[i][5] == 1:
			if b[i][3] == 0:
				if y[i] < y_range[1]:
					y_range[1] = y[i]
		elif b[i][3] == 1:
			if y[i] > y_range[0]:
				y_range[0] = y[i]
		else:
			if y[i] < y_range[1]:
				y_range[1] = y[i]
			if y[i] > y_range[0]:
				y_range[0] = y[i]
		if x_range[0] > x_range[1] or y_range[0] > y_range[1]:
			print(0)
			break
		if i == n - 1:
			print(1, x_range[0], y_range[0])


import sys
input = sys.stdin.readline
q = int(input())
n = 0
(x, y) = (0, 0)
(f1, f2, f3, f4) = (0, 0, 0, 0)
(tx, ty) = (0, 0)
(mnx, mxx, mny, mxy) = (0, 0, 0, 0)
for i in range(q):
	n = int(input())
	mnx = -100000
	mxx = 100000
	mny = -100000
	mxy = 100000
	for j in range(n):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		if f1 == 0:
			mnx = max(mnx, x)
		if f2 == 0:
			mxy = min(mxy, y)
		if f3 == 0:
			mxx = min(mxx, x)
		if f4 == 0:
			mny = max(mny, y)
	if mnx <= mxx and mny <= mxy:
		print(1, mnx, mny)
	else:
		print(0)


q = int(input())
for i in range(q):
	n = int(input())
	l = -100000
	t = 100000
	r = 100000
	b = -100000
	for j in range(n):
		(x, y, f1, f2, f3, f4) = list(map(int, input().split()))
		if f1 == 0:
			if l <= x:
				l = x
		if f2 == 0:
			if t >= y:
				t = y
		if f3 == 0:
			if r >= x:
				r = x
		if f4 == 0:
			if b <= y:
				b = y
	(cx, cy) = (None, None)
	ans = 1
	if l <= r:
		cx = l
	else:
		ans = 0
	if b <= t:
		cy = b
	else:
		ans = 0
	if ans == 0:
		print(ans)
	else:
		print(ans, cx, cy)


import sys
n = int(sys.stdin.readline())
printval = False
for i in range(n):
	k = int(sys.stdin.readline())
	robots = []
	rangox = [-100000.0, 100000.0]
	goodx = True
	rangoy = [-100000.0, 100000.0]
	goody = True
	for j in range(k):
		robotj = [int(p) for p in sys.stdin.readline().split()]
		if goodx and goody:
			x = robotj[0]
			IZQ = robotj[2]
			DER = robotj[4]
			y = robotj[1]
			ARR = robotj[3]
			ABA = robotj[5]
			if x >= rangox[0] and x <= rangox[1]:
				if IZQ == 0:
					rangox[0] = x
				if DER == 0:
					rangox[1] = x
			elif x < rangox[0] and DER or (x > rangox[1] and IZQ):
				pass
			else:
				goodx = False
			if y >= rangoy[0] and y <= rangoy[1]:
				if ABA == 0:
					rangoy[0] = y
				if ARR == 0:
					rangoy[1] = y
			elif y < rangoy[0] and ARR or (y > rangoy[1] and ABA):
				pass
			else:
				goody = False
	if goodx == True and goody == True:
		print('1 {0} {1}'.format(int(rangox[0]), int(rangoy[0])))
	else:
		print('0')


maximum = 10 ** 5
q = int(input())
for i in range(q):
	n = int(input())
	(x1, y1) = (-maximum, -maximum)
	(x2, y2) = (maximum, maximum)
	for z in range(n):
		(x, y, f1, f2, f3, f4) = [int(j) for j in input().split()]
		if not f1:
			if x > x1:
				x1 = x
		if not f2:
			if y < y2:
				y2 = y
		if not f3:
			if x < x2:
				x2 = x
		if not f4:
			if y > y1:
				y1 = y
	if x2 - x1 < 0 or y2 - y1 < 0:
		print(0)
	else:
		print(1, x1, y1)


for q in range(int(input())):
	n = int(input())
	(min_x, min_y, max_x, max_y) = (-10 ** 5, -10 ** 5, 10 ** 5, 10 ** 5)
	for i in range(n):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		if f1 == 0:
			min_x = max(min_x, x)
		if f2 == 0:
			max_y = min(max_y, y)
		if f3 == 0:
			max_x = min(max_x, x)
		if f4 == 0:
			min_y = max(min_y, y)
	if min_x <= max_x and min_y <= max_y:
		print(1, min_x, min_y)
	else:
		print(0)


q = int(input())
for _ in range(q):
	n = int(input())
	bot = left = -100000
	top = right = 100000
	for i in range(n):
		(x, y, l, u, r, d) = map(int, input().split())
		if l == 0:
			left = max(left, x)
		if r == 0:
			right = min(right, x)
		if u == 0:
			top = min(top, y)
		if d == 0:
			bot = max(bot, y)
	if top >= bot and right >= left:
		print(1, left, bot)
	else:
		print(0)


for rpt in range(int(input())):
	robotnum = int(input())
	robots = []
	for i in range(robotnum):
		robots.append([int(x) for x in input().split(' ')])
	robots.sort()
	left = -10 ** 5
	right = 10 ** 5
	up = 10 ** 5
	down = -10 ** 5
	for i in robots:
		if i[2] == 0 and i[0] > left:
			left = i[0]
		if i[3] == 0 and i[1] < up:
			up = i[1]
		if i[4] == 0 and i[0] < right:
			right = i[0]
		if i[5] == 0 and i[1] > down:
			down = i[1]
	if left <= right and down <= up:
		print(str(1) + ' ' + str(left) + ' ' + str(down))
	else:
		print(0)


for _ in range(int(input())):
	n = int(input())
	flag = True
	xx = [-10 ** 5, 10 ** 5]
	yy = [-10 ** 5, 10 ** 5]
	for i in range(n):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		if f1 == 1 and f3 == 0:
			if x < xx[0]:
				flag = False
			if x >= xx[0]:
				if x < xx[1]:
					xx[1] = x
		elif f1 == 0 and f3 == 1:
			if x > xx[1]:
				flag = False
			if x <= xx[1]:
				if x > xx[0]:
					xx[0] = x
		elif f1 == 0 and f3 == 0:
			if x >= xx[0] and x <= xx[1]:
				xx[0] = x
				xx[1] = x
			else:
				flag = False
		if f4 == 1 and f2 == 0:
			if y < yy[0]:
				flag = False
			if y >= yy[0]:
				if y < yy[1]:
					yy[1] = y
		elif f4 == 0 and f2 == 1:
			if y > yy[1]:
				flag = False
			if y <= yy[1]:
				if y > yy[0]:
					yy[0] = y
		elif f4 == 0 and f2 == 0:
			if y >= yy[0] and y <= yy[1]:
				yy[0] = y
				yy[1] = y
			else:
				flag = False
	if not flag:
		print(0)
	else:
		print(1, xx[0], yy[0])


inf = 10 ** 5
import sys
for _ in range(int(input())):
	n = int(sys.stdin.readline())
	a = []
	for i in range(n):
		a.append(list(map(int, sys.stdin.readline().split())))
	xl = -inf
	xh = 10 ** 5
	yl = -inf
	yh = 10 ** 5
	for i in range(n):
		if a[i][2] == 0:
			xl = max(xl, a[i][0])
		else:
			xl = max(xl, -inf)
		if a[i][3] == 0:
			yh = min(yh, a[i][1])
		else:
			yh = min(yh, 10 ** 5)
		if a[i][4] == 0:
			xh = min(xh, a[i][0])
		else:
			xh = min(xh, 10 ** 5)
		if a[i][5] == 0:
			yl = max(yl, a[i][1])
		else:
			yl = max(yl, -inf)
	if xl <= xh and yl <= yh:
		print(1, xl, yl)
	else:
		print(0)


from sys import stdin, stdout
c = int(stdin.readline().strip())
for cas in range(c):
	n = int(stdin.readline().strip())
	s = [list(map(int, stdin.readline().strip().split())) for i in range(n)]
	mn = -10 ** 5
	interval = [[mn, -mn], [mn, -mn]]
	flag = True
	for i in s:
		if i[2] == 0:
			if interval[0][1] < i[0]:
				flag = False
				break
			else:
				interval[0][0] = max(i[0], interval[0][0])
		if i[3] == 0:
			if interval[1][0] > i[1]:
				flag = False
				break
			else:
				interval[1][1] = min(interval[1][1], i[1])
		if i[4] == 0:
			if interval[0][0] > i[0]:
				flag = False
				break
			else:
				interval[0][1] = min(interval[0][1], i[0])
		if i[5] == 0:
			if interval[1][1] < i[1]:
				flag = False
				break
			else:
				interval[1][0] = max(interval[1][0], i[1])
	if flag:
		stdout.write('%d %d %d\n' % (1, interval[0][0], interval[1][0]))
	else:
		stdout.write('0\n')


import sys
for q in range(int(input())):
	mxx = 10 ** 5
	mxy = 10 ** 5
	mnx = -10 ** 5
	mny = -10 ** 5
	for n in range(int(input())):
		(x, y, f1, f2, f3, f4) = map(int, sys.stdin.readline().split())
		if f1 == 0:
			mnx = max(x, mnx)
		if f2 == 0:
			mxy = min(y, mxy)
		if f3 == 0:
			mxx = min(x, mxx)
		if f4 == 0:
			mny = max(y, mny)
	if mnx <= mxx and mny <= mxy:
		print(1, mnx, mny)
	else:
		print(0)


import math
from sys import stdin, stdout
from bisect import bisect_left, bisect_right

def isprime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def freq(l):
	f = {}
	for i in l:
		if i in f:
			f[i] += 1
		else:
			f[i] = 1
	return f
MAX = pow(10, 5)
inp = lambda : int(stdin.readline())
sip = lambda : stdin.readline()
mulip = lambda : map(int, stdin.readline().split())
lst = lambda : list(map(int, stdin.readline().split()))
slst = lambda : list(sip())
for _ in range(inp()):
	n = inp()
	(maxx, maxy, minx, miny) = (MAX, MAX, -MAX, -MAX)
	for _ in range(n):
		(x, y, f1, f2, f3, f4) = mulip()
		if f2 == 0:
			maxy = min(maxy, y)
		if f4 == 0:
			miny = max(miny, y)
		if f3 == 0:
			maxx = min(maxx, x)
		if f1 == 0:
			minx = max(minx, x)
	if minx <= maxx and miny <= maxy:
		print(1, minx, miny)
	else:
		print(0)


def intersect(rec1, rec2):
	if rec1[0] > rec2[1] or rec2[0] > rec1[1] or rec1[2] < rec2[3] or (rec2[2] < rec1[3]):
		return False
	else:
		xs = [rec1[0], rec1[1], rec2[0], rec2[1]]
		xs = sorted(xs)
		x1 = xs[1]
		x2 = xs[2]
		ys = [rec1[2], rec1[3], rec2[2], rec2[3]]
		ys = sorted(ys)
		y1 = ys[2]
		y2 = ys[1]
	return [x1, x2, y1, y2]
q = int(input())
inf = float('inf')
minf = float('-inf')
for _ in range(q):
	N = int(input())
	ok = True
	ss = []
	for i in range(N):
		ss.append(list(map(int, input().rstrip().split())))
	rec = [minf, inf, inf, minf]
	for s in ss:
		x0 = s[0]
		y0 = s[1]
		_sum = s[2] + s[3] + s[4] + s[5]
		if _sum == 0:
			if rec[0] <= x0 and x0 <= rec[1] and (rec[3] <= y0) and (y0 <= rec[2]):
				rec = [x0, x0, y0, y0]
				continue
			else:
				print(0)
				ok = False
				break
		elif _sum == 1:
			if s[2] == 1:
				nrec = [minf, x0, y0, y0]
			elif s[3] == 1:
				nrec = [x0, x0, inf, y0]
			elif s[4] == 1:
				nrec = [x0, inf, y0, y0]
			elif s[5] == 1:
				nrec = [x0, x0, y0, minf]
		elif _sum == 2:
			if s[2] == 1 and s[3] == 1:
				nrec = [minf, x0, inf, y0]
			elif s[2] == 1 and s[4] == 1:
				nrec = [minf, inf, y0, y0]
			elif s[2] == 1 and s[5] == 1:
				nrec = [minf, x0, y0, minf]
			elif s[3] == 1 and s[4] == 1:
				nrec = [x0, inf, inf, y0]
			elif s[3] == 1 and s[5] == 1:
				nrec = [x0, x0, inf, minf]
			elif s[4] == 1 and s[5] == 1:
				nrec = [x0, inf, y0, minf]
		elif _sum == 3:
			if s[2] == 0:
				nrec = [x0, inf, inf, minf]
			elif s[3] == 0:
				nrec = [minf, inf, y0, minf]
			elif s[4] == 0:
				nrec = [minf, x0, inf, minf]
			elif s[5] == 0:
				nrec = [minf, inf, inf, y0]
		else:
			continue
		rec = intersect(rec, nrec)
		if not rec:
			print(0)
			ok = False
			break
	if not ok:
		continue
	if rec[0] == float('-inf'):
		rec[0] = -100000
	elif rec[0] == float('inf'):
		rec[0] = 1000000
	if rec[3] == float('-inf'):
		rec[3] = -100000
	elif rec[3] == float('inf'):
		rec[3] = 1000000
	print('1 ' + str(rec[0]) + ' ' + str(rec[3]))


q = int(input())
for _ in range(q):
	n = int(input())
	mat = []
	rng = []
	xmin = -100000
	xmax = 100000
	ymin = -100000
	ymax = 100000
	for i in range(n):
		arr = list(map(int, input().split()))
		x = arr[0]
		y = arr[1]
		f = arr[2:]
		mat.append(f)
		if f[0] == 1:
			xmni = -100000
		else:
			xmni = x
		if f[1] == 1:
			ymxi = 100000
		else:
			ymxi = y
		if f[2] == 1:
			xmxi = 100000
		else:
			xmxi = x
		if f[3] == 1:
			ymni = -100000
		else:
			ymni = y
		rng.append([xmni, xmxi, ymni, ymxi])
	flag = 1
	for i in range(n):
		ri = rng[i]
		if ri[0] > xmax or ri[1] < xmin or ri[2] > ymax or (ri[3] < ymin):
			flag = 0
			break
		else:
			xmin = max(ri[0], xmin)
			xmax = min(ri[1], xmax)
			ymin = max(ri[2], ymin)
			ymax = min(ri[3], ymax)
	if flag == 0:
		print(flag)
	else:
		print(flag, xmin, ymin)


q = int(input())
for _ in range(q):
	n = int(input())
	x = [-100000, 100000]
	y = [-100000, 100000]
	for _ in range(n):
		(a, b, left, top, right, bot) = map(int, input().split())
		if left == 0:
			if a >= x[0]:
				x[0] = a
		if top == 0:
			if b <= y[1]:
				y[1] = b
		if right == 0:
			if a <= x[1]:
				x[1] = a
		if bot == 0:
			if b >= y[0]:
				y[0] = b
	if x[0] <= x[1] and y[0] <= y[1]:
		print(1, x[0], y[0])
	else:
		print(0)


from sys import stdin, stdout
from collections import Counter
import math

def rsingle_int():
	return int(stdin.readline().rstrip())

def rmult_int():
	return [int(x) for x in stdin.readline().rstrip().split()]

def rmult_str():
	return stdin.readline().rstrip().split()

def r_str():
	return stdin.readline().rstrip()

def rsingle_char():
	return stdin.read(1)

def main():
	q = rsingle_int()
	for i in range(q):
		n = rsingle_int()
		(l, r, t, b) = (-100001, 100001, 100001, -100001)
		for j in range(n):
			a = rmult_int()
			if not a[2]:
				lr = a[0] - 1
				if lr > l:
					l = lr
			if not a[3]:
				tr = a[1] + 1
				if tr < t:
					t = tr
			if not a[4]:
				rr = a[0] + 1
				if rr < r:
					r = rr
			if not a[5]:
				br = a[1] - 1
				if br > b:
					b = br
		if r - l >= 2 and t - b >= 2:
			x = l + 1
			y = b + 1
			print(*[1, x, y])
		else:
			print(0)
main()


q = int(input())
for _ in range(q):
	n = int(input())
	x = []
	y = []
	f = []
	for _ in range(n):
		temp = tuple(map(int, input().split()))
		x.append(temp[0])
		y.append(temp[1])
		f.append(temp[2:])
	x_min = y_min = -100000
	x_max = y_max = 100000
	for i in range(n):
		if f[i][0] == 0:
			x_min = max(x_min, x[i])
		if f[i][1] == 0:
			y_max = min(y_max, y[i])
		if f[i][2] == 0:
			x_max = min(x_max, x[i])
		if f[i][3] == 0:
			y_min = max(y_min, y[i])
	if x_max < x_min:
		print(0)
		continue
	elif y_max < y_min:
		print(0)
		continue
	else:
		print('1 %d %d' % (x_min, y_min))


INF = 100000
for i in range(int(input())):
	(x1, y1, x2, y2) = (-INF, -INF, INF, INF)
	for i in range(int(input())):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		if not f1:
			x1 = max(x1, x)
		if not f2:
			y2 = min(y2, y)
		if not f3:
			x2 = min(x2, x)
		if not f4:
			y1 = max(y1, y)
	if x1 > x2 or y1 > y2:
		print(0)
	else:
		print(1, x1, y1)


for _ in range(int(input())):
	n = int(input())
	robots = []
	ans_limit = [-100000, 100000, 100000, -100000]
	for i in range(n):
		robots.append([int(j) for j in input().split()])
	for i in robots:
		if i[2] == 0 and i[0] > ans_limit[0]:
			ans_limit[0] = i[0]
		if i[3] == 0 and i[1] < ans_limit[1]:
			ans_limit[1] = i[1]
		if i[4] == 0 and i[0] < ans_limit[2]:
			ans_limit[2] = i[0]
		if i[5] == 0 and i[1] > ans_limit[3]:
			ans_limit[3] = i[1]
	if ans_limit[0] > ans_limit[2]:
		print(0)
	elif ans_limit[1] < ans_limit[3]:
		print(0)
	else:
		print(1, ans_limit[0], ans_limit[3])


def main():
	import sys
	input = sys.stdin.readline

	def solve():
		n = int(input())
		maxx = 10 ** 5
		minx = -10 ** 5
		maxy = 10 ** 5
		miny = -10 ** 5
		for _ in range(n):
			(x, y, f1, f2, f3, f4) = map(int, input().split())
			if not f1:
				minx = max(minx, x)
			if not f2:
				maxy = min(maxy, y)
			if not f3:
				maxx = min(maxx, x)
			if not f4:
				miny = max(miny, y)
		if minx > maxx or miny > maxy:
			print(0)
		else:
			print(1, minx, miny)
	for _ in range(int(input())):
		solve()
	return 0
main()


q = int(input())
for _ in range(q):
	n = int(input())
	(minx, maxx, miny, maxy) = (-100000, 100000, -100000, 100000)
	for i in range(n):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		if f1 == 0:
			minx = max(x, minx)
		if f3 == 0:
			maxx = min(maxx, x)
		if f2 == 0:
			maxy = min(maxy, y)
		if f4 == 0:
			miny = max(y, miny)
	if minx > maxx or miny > maxy:
		print(0)
		continue
	else:
		print(1, minx, miny)


import sys
q = int(sys.stdin.readline())
ans_arr = []
for i in range(q):
	n = int(sys.stdin.readline())
	arr = []
	for j in range(n):
		a = [int(i) for i in sys.stdin.readline().split()]
		arr.append(a)
	maxy = 100000
	for g in range(n):
		if arr[g][3] == 0:
			maxy = min(maxy, arr[g][1])
	miny = -100000
	for h in range(n):
		if arr[h][5] == 0:
			miny = max(miny, arr[h][1])
	maxx = 100000
	for p in range(n):
		if arr[p][4] == 0:
			maxx = min(maxx, arr[p][0])
	minx = -100000
	for q in range(n):
		if arr[q][2] == 0:
			minx = max(minx, arr[q][0])
	if minx > maxx or miny > maxy:
		ans_arr.append('0')
	else:
		ans_arr.append('1 ' + str(minx) + ' ' + str(miny))
print('\n'.join(ans_arr))


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import ceil, floor
from copy import *
from collections import deque, defaultdict
from collections import Counter as counter
from itertools import combinations
from itertools import permutations as permutate
from bisect import bisect_left as bl
from operator import *
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192
from sys import stderr

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def fsep():
	return map(float, inp().split())

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def pow(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def gcd(a, b):
	if a == b:
		return a
	while b > 0:
		(a, b) = (b, a % b)
	return a

def prefix_sum(ar):
	return list(accumulate(ar))

def suffix_sum(ar):
	return list(accumulate(ar[::-1]))[::-1]

def N():
	return int(inp())
dx = [0, 0, 1, -1]
dy = [1, -1, 0, 0]
from collections import defaultdict

def numberOfSetBits(i):
	i = i - (i >> 1 & 1431655765)
	i = (i & 858993459) + (i >> 2 & 858993459)
	return ((i + (i >> 4) & 252645135) * 16843009 & 4294967295) >> 24
from decimal import *
from math import *

def solve():
	n = N()
	inf = 100000
	xrange = [-inf, inf]
	yrange = [-inf, inf]
	for _ in range(n):
		(a, b, l, u, r, d) = sep()
		if not l:
			xrange[0] = max(xrange[0], a)
		if not u:
			yrange[1] = min(yrange[1], b)
		if not r:
			xrange[1] = min(xrange[1], a)
		if not d:
			yrange[0] = max(yrange[0], b)
	if xrange[0] <= xrange[1] and yrange[0] <= yrange[1]:
		print(1, xrange[0], yrange[0])
	else:
		print(0)
testcase(int(inp()))


q = int(input())
for _ in range(q):
	n = int(input())
	x0 = -100000
	x1 = 100000
	y0 = -100000
	y1 = 100000
	for _ in range(n):
		(x, y, left, up, right, down) = map(int, input().split())
		if not left:
			x0 = max(x0, x)
		if not right:
			x1 = min(x1, x)
		if not up:
			y1 = min(y1, y)
		if not down:
			y0 = max(y0, y)
	if x0 <= x1 and y0 <= y1:
		print(1, x0, y0)
	else:
		print(0)


q = int(input())

def solve():
	n = int(input())
	(min_x, max_x, min_y, max_y) = (-100000, 100000, -100000, 100000)
	for _ in range(n):
		(x, y, f1, f2, f3, f4) = [int(x) for x in input().split()]
		if f1 == 0:
			min_x = max(min_x, x)
		if f2 == 0:
			max_y = min(max_y, y)
		if f3 == 0:
			max_x = min(max_x, x)
		if f4 == 0:
			min_y = max(min_y, y)
	if min_x > max_x or min_y > max_y:
		print(0)
	else:
		print(1, min_x, min_y)
for _ in range(q):
	solve()


q = int(input())
while q > 0:
	n = int(input())
	max_x = max_y = 100000.0
	min_x = min_y = -100000.0
	while n > 0:
		[x, y, f1, f2, f3, f4] = [int(x) for x in input().split()]
		if f1 == 0:
			min_x = max(min_x, x)
		if f2 == 0:
			max_y = min(max_y, y)
		if f3 == 0:
			max_x = min(max_x, x)
		if f4 == 0:
			min_y = max(min_y, y)
		n -= 1
	if min_x > max_x or min_y > max_y:
		print(0)
	else:
		print(1, int(min_x), int(min_y))
	q -= 1


def intersection(X, curr, x):
	if curr == 'a':
		if X[0] > x:
			return []
		X[1] = min(X[1], x)
	else:
		if X[1] < x:
			return []
		X[0] = max(X[0], x)
	return X

def solve(n, ans):
	found = True
	X = [-10 ** 5, 10 ** 5]
	Y = [-10 ** 5, 10 ** 5]
	for i in range(n):
		(x, y, a, b, c, d) = map(int, input().split())
		if found:
			if a + c == 1:
				if a == 1:
					if not intersection(X, 'a', x):
						found = False
				elif not intersection(X, 'c', x):
					found = False
			elif a + c == 0:
				if X[0] <= x and X[1] >= x:
					X = [x, x]
				else:
					found = False
			if b + d == 1:
				if d == 1:
					if not intersection(Y, 'a', y):
						found = False
				elif not intersection(Y, 'c', y):
					found = False
			elif b + d == 0:
				if Y[0] <= y and Y[1] >= y:
					Y = [y, y]
				else:
					found = False
	if not found:
		ans.append(0)
	else:
		ans.append('1 ' + str(X[0]) + ' ' + str(Y[0]))

def main():
	ans = []
	q = int(input())
	for i in range(q):
		n = int(input())
		solve(n, ans)
	for i in ans:
		print(i)
main()


M = 100000
q = int(input().strip())
for t in range(q):
	minx = -M
	miny = -M
	maxx = M
	maxy = M
	n = int(input().strip())
	for r in range(n):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		if f1 == 0:
			minx = max(x, minx)
		if f2 == 0:
			maxy = min(y, maxy)
		if f3 == 0:
			maxx = min(x, maxx)
		if f4 == 0:
			miny = max(y, miny)
	if minx > maxx or miny > maxy:
		print(0)
	else:
		print(str(1) + ' ' + str(minx) + ' ' + str(miny))


for _ in range(int(input())):
	x_min = -100000
	x_max = 100000
	y_min = -100000
	y_max = 100000
	for _ in range(int(input())):
		(x, y, left, up, right, down) = map(int, input().split())
		if not left:
			x_min = max(x_min, x)
		if not up:
			y_max = min(y_max, y)
		if not right:
			x_max = min(x_max, x)
		if not down:
			y_min = max(y_min, y)
	if x_min <= x_max and y_min <= y_max:
		print('1 ' + str(x_min) + ' ' + str(y_min))
	else:
		print('0')


from collections import Counter, defaultdict, deque
import heapq as hq
import itertools
import math
import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	xmin = -10 ** 5
	xmax = 10 ** 5
	ymin = -10 ** 5
	ymax = 10 ** 5
	for r in range(n):
		arr = [int(x) for x in input().split()]
		f = arr[2:]
		if f[0] == 0:
			xmin = max(xmin, arr[0])
		if f[1] == 0:
			ymax = min(ymax, arr[1])
		if f[2] == 0:
			xmax = min(xmax, arr[0])
		if f[3] == 0:
			ymin = max(ymin, arr[1])
	if ymin <= ymax and xmin <= xmax:
		print(1, xmin, ymin)
	else:
		print(0)
tt = int(input())
for test in range(tt):
	solve()


t = int(input())
for j in range(t):
	n = int(input())
	xmin = -100000
	xmax = 100000
	ymin = -100000
	ymax = 100000
	flag = 0
	for i in range(n):
		x = list(map(int, input().split()))
		if x[2] == 0:
			xmin = max(xmin, x[0])
		if x[3] == 0:
			ymax = min(x[1], ymax)
		if x[4] == 0:
			xmax = min(x[0], xmax)
		if x[5] == 0:
			ymin = max(x[1], ymin)
		if xmin > xmax or ymin > ymax:
			flag = 1
	if flag == 1:
		print(0)
	else:
		print(1, xmin, ymin)


def solve():
	n = int(input())
	x_d = [-100000, 100000]
	y_d = [-100000, 100000]
	robots = []
	for i in range(n):
		robots.append([int(i) for i in input().split(' ')])
	for r in robots:
		(x, y, l, u, r, d) = r
		if l == 0 and r == 0:
			if x_d[0] > x or x_d[1] < x:
				return '0'
			x_d = [x, x]
		if u == 0 and d == 0:
			if y_d[0] > y or y_d[1] < y:
				return '0'
			y_d = [y, y]
		if l == 0:
			if x_d[1] < x:
				return '0'
			x_d[0] = max(x, x_d[0])
		if r == 0:
			if x_d[0] > x:
				return '0'
			x_d[1] = min(x, x_d[1])
		if d == 0:
			if y_d[1] < y:
				return '0'
			y_d[0] = max(y, y_d[0])
		if u == 0:
			if y_d[0] > y:
				return '0'
			y_d[1] = min(y, y_d[1])
	return ' '.join((str(i) for i in [1, x_d[0], y_d[0]]))
q = int(input())
o = ''
for _ in range(q):
	o += solve() + '\n'
print(o)


import sys
input = sys.stdin.readline
t = int(input())
for ll in range(t):
	n = int(input())
	maxy = 10 ** 5
	miny = -10 ** 5
	maxx = 10 ** 5
	minx = -10 ** 5
	for i in range(n):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		if f2 == 0:
			maxy = min(maxy, y)
		if f4 == 0:
			miny = max(miny, y)
		if f3 == 0:
			maxx = min(maxx, x)
		if f1 == 0:
			minx = max(minx, x)
	if minx > maxx or miny > maxy:
		print(0)
	else:
		print(1, minx, miny)


q = int(input())
for i in range(q):
	n = int(input())
	laveX = []
	praveX = []
	dolneY = []
	horneY = []
	for j in range(n):
		[x, y, f1, f2, f3, f4] = [int(z) for z in input().split()]
		if f1 == 1:
			laveX.append(-10 ** 5)
		else:
			laveX.append(x)
		if f3 == 1:
			praveX.append(10 ** 5)
		else:
			praveX.append(x)
		if f2 == 1:
			horneY.append(10 ** 5)
		else:
			horneY.append(y)
		if f4 == 1:
			dolneY.append(-10 ** 5)
		else:
			dolneY.append(y)
	dolny = max(dolneY)
	horny = min(horneY)
	pravy = min(praveX)
	lavy = max(laveX)
	if horny >= dolny and pravy >= lavy:
		print('1 ' + str(lavy) + ' ' + str(dolny))
	else:
		print('0')


mod = 10 ** 5
for _ in range(int(input())):
	n = int(input())
	(x, y) = ([-1 * mod, mod], [-1 * mod, mod])
	ans = True
	for i in range(n):
		l = list(map(int, input().split()))
		(xl, xu, yl, yu) = (-1 * mod, mod, -1 * mod, mod)
		if l[2] == 0:
			xl = l[0]
		if l[3] == 0:
			yu = l[1]
		if l[4] == 0:
			xu = l[0]
		if l[5] == 0:
			yl = l[1]
		if (xl > x[1] or xu < x[0]) or (yl > y[1] or yu < y[0]):
			ans = False
		else:
			x[0] = max(x[0], xl)
			y[0] = max(y[0], yl)
			x[1] = min(x[1], xu)
			y[1] = min(y[1], yu)
	if ans:
		print(1, x[0], y[0])
	else:
		print(0)


q = int(input())
for i in range(q):
	n = int(input())
	xl = -100000
	xr = 100000
	yl = -100000
	yr = 100000
	for j in range(n):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		if f1 == 0 and x >= xl:
			xl = x
		if f3 == 0 and x <= xr:
			xr = x
		if f4 == 0 and y >= yl:
			yl = y
		if f2 == 0 and y <= yr:
			yr = y
	if xl <= xr and yl <= yr:
		print(1, min(xl, xr), min(yl, yr))
	else:
		print(0)


q = int(input())
for i in range(q):
	n = int(input())
	xr = [-100000, +100000]
	yr = [-100000, +100000]
	for j in range(n):
		data = tuple(map(int, input().split()))
		x = data[0]
		y = data[1]
		if not data[2]:
			xr[0] = max(x, xr[0])
		if not data[4]:
			xr[1] = min(x, xr[1])
		if not data[3]:
			yr[1] = min(y, yr[1])
		if not data[5]:
			yr[0] = max(y, yr[0])
	if yr[0] > yr[1] or xr[0] > xr[1]:
		print(0)
	else:
		print(1, xr[0], yr[0])


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline())
	(min_x, min_y) = (-100000, -100000)
	(max_x, max_y) = (100000, 100000)
	for i in range(n):
		(x, y, f1, f2, f3, f4) = map(int, sys.stdin.readline().split())
		if not f1:
			min_x = max(min_x, x)
		if not f2:
			max_y = min(max_y, y)
		if not f3:
			max_x = min(max_x, x)
		if not f4:
			min_y = max(min_y, y)
	if min_x <= max_x and min_y <= max_y:
		print(1, min_x, min_y)
	else:
		print(0)


q = int(input())
for i in range(q):
	x = []
	y = []
	f = []
	n = int(input())
	for i in range(n):
		(xi, yi, fi) = input().split(' ', 2)
		(xi, yi) = (int(xi), int(yi))
		fi = list(map(int, fi.split()))
		x.append(xi)
		y.append(yi)
		f.append(fi)
	no_left = [x[i] for i in range(n) if f[i][0] == 0]
	no_up = [y[i] for i in range(n) if f[i][1] == 0]
	no_right = [x[i] for i in range(n) if f[i][2] == 0]
	no_down = [y[i] for i in range(n) if f[i][3] == 0]
	if len(no_left) == 0:
		x1 = -100000
	else:
		x1 = max(no_left)
	if len(no_up) == 0:
		y2 = 100000
	else:
		y2 = min(no_up)
	if len(no_right) == 0:
		x2 = 100000
	else:
		x2 = min(no_right)
	if len(no_down) == 0:
		y1 = -100000
	else:
		y1 = max(no_down)
	if x2 >= x1 and y2 >= y1:
		print(1, x1, y1)
	else:
		print(0)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	X = [-10 ** 5, 10 ** 5]
	Y = [-10 ** 5, 10 ** 5]
	flag = True
	for _ in range(n):
		(x, y, left, down, right, up) = map(int, input().split())
		(x_lb, x_ub) = (-10 ** 5, 10 ** 5)
		(y_lb, y_ub) = (-10 ** 5, 10 ** 5)
		if left == 0 and right == 0:
			x_lb = x_ub = x
		elif left == 0:
			x_lb = x
		elif right == 0:
			x_ub = x
		if up == 0 and down == 0:
			y_lb = y_ub = y
		elif up == 0:
			y_lb = y
		elif down == 0:
			y_ub = y
		if X[1] < x_lb or x_ub < X[0] or Y[1] < y_lb or (y_ub < Y[0]):
			flag = False
		else:
			X[0] = max(X[0], x_lb)
			X[1] = min(X[1], x_ub)
			Y[0] = max(Y[0], y_lb)
			Y[1] = min(Y[1], y_ub)
	if flag:
		print(1, X[0], Y[0])
	else:
		print(0)


q = int(input())
for z in range(q):
	n = int(input())
	robots = []
	for k in range(n):
		r = [-10 ** 5, 10 ** 5, -10 ** 5, 10 ** 5]
		t = list(map(int, input().split()))
		if t[2] == 0:
			r[0] = t[0]
		if t[3] == 0:
			r[3] = t[1]
		if t[4] == 0:
			r[1] = t[0]
		if t[5] == 0:
			r[2] = t[1]
		robots.append(r)
	f = 1
	(xmin, XMAX, ymin, YMAX) = (-10 ** 5, 10 ** 5, -10 ** 5, 10 ** 5)
	for e in robots:
		if e[1] < xmin or e[0] > XMAX or e[3] < ymin or (e[2] > YMAX):
			f = 0
			pass
		else:
			(xmin, XMAX, ymin, YMAX) = (max(xmin, e[0]), min(XMAX, e[1]), max(ymin, e[2]), min(YMAX, e[3]))
	if f == 1:
		print(1, xmin, ymin)
	else:
		print(0)


from sys import stdin
MAX = int(100000.0)
for _ in range(int(input())):
	n = int(input())
	(max_x, max_y) = (MAX, MAX)
	(min_x, min_y) = (-MAX, -MAX)
	for _ in range(n):
		(x, y, L, U, R, D) = map(int, stdin.readline().split())
		if not L:
			min_x = max(min_x, x)
		if not U:
			max_y = min(max_y, y)
		if not R:
			max_x = min(max_x, x)
		if not D:
			min_y = max(min_y, y)
	if min_x <= max_x and min_y <= max_y:
		print(f'1 {min_x} {min_y}')
	else:
		print(0)


from sys import stdin
from math import inf
q = int(stdin.readline())

class Rect:

	def __init__(self, x1=-inf, y1=-inf, x2=inf, y2=inf):
		if x1 > x2:
			(x1, x2) = (x2, x1)
		if y1 > y2:
			(y1, y2) = (y2, y1)
		self.x1 = x1
		self.y1 = y1
		self.x2 = x2
		self.y2 = y2

	def __str__(self):
		return '(%f, %f, %f, %f)' % (self.x1, self.y1, self.x2, self.y2)

def intersect(r1, r2):
	if r1 is None or r2 is None:
		return None
	if r1.x2 < r2.x1 or r2.x2 < r1.x1:
		return None
	if r1.y2 < r2.y1 or r2.y2 < r1.y1:
		return None
	return Rect(max(r1.x1, r2.x1), max(r1.y1, r2.y1), min(r1.x2, r2.x2), min(r1.y2, r2.y2))
for i in range(q):
	n = int(stdin.readline())
	inter = Rect()
	for i in range(n):
		(x, y, f1, f2, f3, f4) = map(int, stdin.readline().split())
		curRect = Rect()
		if f1 == 0:
			curRect.x1 = x
		if f2 == 0:
			curRect.y2 = y
		if f3 == 0:
			curRect.x2 = x
		if f4 == 0:
			curRect.y1 = y
		inter = intersect(inter, curRect)
	if inter is None:
		print('0')
	else:
		print('1 %d %d' % (int(max(inter.x1, -10 ** 5)), int(max(inter.y1, -10 ** 5))))


import sys
import math
from collections import defaultdict
input = sys.stdin.readline

def main():
	q = int(input())
	for _ in range(q):
		minx = miny = -math.inf
		maxx = maxy = math.inf
		n = int(input())
		for _ in range(n):
			(x, y, f1, f2, f3, f4) = map(int, input().split())
			if f1 == 0:
				minx = max(minx, x)
			if f2 == 0:
				maxy = min(maxy, y)
			if f3 == 0:
				maxx = min(maxx, x)
			if f4 == 0:
				miny = max(miny, y)
		minx = max(minx, -100000)
		miny = max(miny, -100000)
		maxx = min(maxx, 100000)
		maxy = min(maxy, 100000)
		if minx <= maxx and miny <= maxy:
			print('1 {} {}'.format(minx, miny))
		else:
			print('0')
main()


def getOverlap(a, b):
	left = max(a[0], b[0])
	right = min(a[1], b[1])
	if left <= right:
		return [left, right]
	return None
inf = 10 ** 5
fun_idx = 2
T = int(input())
for t in range(T):
	n = int(input())
	A = []
	for i in range(n):
		f = list(map(int, input().split()))
		A.append(f)
	intervals = []
	for i in range(n):
		l = r = A[i][0]
		if A[i][fun_idx + 0] == 1:
			l = -inf
		if A[i][fun_idx + 2] == 1:
			r = inf
		intervals.append([l, r])
	ans_x = intervals[0]
	i = 1
	while ans_x is not None and i < n:
		ans_x = getOverlap(ans_x, intervals[i])
		i += 1
	intervals = []
	for i in range(n):
		l = r = A[i][1]
		if A[i][fun_idx + 1] == 1:
			r = inf
		if A[i][fun_idx + 3] == 1:
			l = -inf
		intervals.append([l, r])
	ans_y = intervals[0]
	i = 1
	while ans_y is not None and i < n:
		ans_y = getOverlap(ans_y, intervals[i])
		i += 1
	if ans_x is None or ans_y is None:
		print(0)
	else:
		print('1 %d %d' % (ans_x[0], ans_y[0]))


q = int(input())
for _ in range(q):
	n = int(input())
	minx = -100000
	maxx = 100000
	miny = -100000
	maxy = 100000
	for i in range(n):
		(x, y, a, b, c, d) = map(int, input().split())
		if a == 0:
			minx = max(minx, x)
		if b == 0:
			maxy = min(maxy, y)
		if c == 0:
			maxx = min(maxx, x)
		if d == 0:
			miny = max(miny, y)
	if minx <= maxx and miny <= maxy:
		print(1, minx, miny)
	else:
		print(0)


q = int(input())
for i in range(q):
	n = int(input())
	rowdown = -10 ** 5
	rowup = 10 ** 5
	colmnleft = -10 ** 5
	colmnright = 10 ** 5
	for j in range(n):
		(x, y, left, up, right, down) = list(map(int, input().split()))
		if not left:
			colmnleft = max(colmnleft, x)
		if not right:
			colmnright = min(colmnright, x)
		if not up:
			rowup = min(rowup, y)
		if not down:
			rowdown = max(rowdown, y)
	if rowdown > rowup or colmnleft > colmnright:
		print(0)
	else:
		print(1, colmnleft, rowdown)


bound = 100000
k = int(input())
for _ in range(k):
	n = int(input())
	xr = [-bound, bound]
	yr = [-bound, bound]
	flag = True
	for __ in range(n):
		(x, y, a1, a2, a3, a4) = [int(x) for x in input().split()]
		cur_xr = [x, x]
		cur_yr = [y, y]
		if a1 == 1:
			cur_xr[0] = -bound
		if a2 == 1:
			cur_yr[1] = bound
		if a3 == 1:
			cur_xr[1] = bound
		if a4 == 1:
			cur_yr[0] = -bound
		xr[0] = max(xr[0], cur_xr[0])
		xr[1] = min(xr[1], cur_xr[1])
		yr[0] = max(yr[0], cur_yr[0])
		yr[1] = min(yr[1], cur_yr[1])
		if xr[0] > xr[1] or yr[0] > yr[1]:
			flag = False
	if flag:
		print(1, xr[0], yr[0])
	else:
		print(0)


import math
import sys
n = int(sys.stdin.readline().strip())
for i in range(n):
	n = int(sys.stdin.readline().strip())
	mx = -math.inf
	px = math.inf
	my = -math.inf
	py = math.inf
	robots = [list(map(int, sys.stdin.readline().split())) for x in range(n)]
	for robot in robots:
		if robot[2] == 0:
			mx = max(robot[0], mx)
		if robot[5] == 0:
			my = max(robot[1], my)
		if robot[4] == 0:
			px = min(robot[0], px)
		if robot[3] == 0:
			py = min(robot[1], py)
	if mx > px or my > py:
		print(0)
	else:
		print(1, max(-100000, mx), max(-100000, my))


ll = lambda : list(map(int, input().split()))
testcases = 1
testcases = int(input())
for testcase in range(testcases):
	[n] = ll()
	cord = []
	f = [[] for i in range(n)]
	for i in range(n):
		[x, y, a, b, c, d] = ll()
		cord.append([x, y])
		f[i] = [a, b, c, d]
	num = 100000
	(xmin, xmax, ymin, ymax) = (-num, num, -num, num)
	for i in range(n):
		if f[i][0] == 0:
			xmin = max(cord[i][0], xmin)
		if f[i][3] == 0:
			ymin = max(cord[i][1], ymin)
		if f[i][2] == 0:
			xmax = min(cord[i][0], xmax)
		if f[i][1] == 0:
			ymax = min(cord[i][1], ymax)
		if xmin > xmax or ymin > ymax:
			print(0)
			break
	else:
		print(1, xmin, ymin)


import sys
q = int(sys.stdin.readline())
for testcases in range(q):
	n = int(sys.stdin.readline())
	ROBOT = [list(map(int, input().split())) for i in range(n)]
	XMAX = 10 ** 5
	XMIN = -10 ** 5
	YMAX = 10 ** 5
	YMIN = -10 ** 5
	for (x, y, a, b, c, d) in ROBOT:
		if a == 0:
			XMIN = max(XMIN, x)
		if b == 0:
			YMAX = min(YMAX, y)
		if c == 0:
			XMAX = min(XMAX, x)
		if d == 0:
			YMIN = max(YMIN, y)
	if XMIN > XMAX or YMIN > YMAX:
		print(0)
	else:
		print(1, XMIN, YMIN)


def rangeMatch(p1, p2):
	(a, b) = p1
	(x, y) = p2
	if b < x or y < a:
		return -1
	return [max(a, x), min(b, y)]
for _ in range(int(input())):
	n = int(input())
	N = 10 ** 5
	X = [-N, N]
	Y = [-N, N]
	ok = True
	for i in range(n):
		(x, y, left, up, right, down) = [int(x) for x in input().split()]
		make_x = [x, x]
		if left:
			make_x[0] = -N
		if right:
			make_x[1] = N
		p = rangeMatch(make_x, X)
		if p != -1:
			X = p
		else:
			ok = False
		make_y = [y, y]
		if down:
			make_y[0] = -N
		if up:
			make_y[1] = N
		p = rangeMatch(make_y, Y)
		if p != -1:
			Y = p
		else:
			ok = False
	if ok:
		print(1, X[0], Y[0])
	else:
		print(0)


for i in range(int(input())):
	n = int(input())
	(x1, x2, y1, y2) = (-100000, 100000, -100000, 100000)
	robots = []
	for j in range(n):
		(x, y, f1, f2, f3, f4) = (int(f) for f in input().split())
		if f1 == 0 and x1 < x:
			x1 = x
		if f2 == 0 and y < y2:
			y2 = y
		if f3 == 0 and x < x2:
			x2 = x
		if f4 == 0 and y1 < y:
			y1 = y
		robots.append((x, y))
	if x2 >= x1 and y2 >= y1:
		print('1', x1, y1)
	else:
		print('0')


q = int(input())
for _ in range(q):
	n = int(input())
	(xmin, ymin) = (-100000, -100000)
	(xmax, ymax) = (100000, 100000)
	for _ in range(n):
		(x, y, f1, f2, f3, f4) = list(map(int, input().split(' ')))[:6]
		if f1 == 0:
			xmin = max(xmin, x)
		if f2 == 0:
			ymax = min(ymax, y)
		if f3 == 0:
			xmax = min(xmax, x)
		if f4 == 0:
			ymin = max(ymin, y)
	if ymin > ymax or xmin > xmax:
		print(0)
	else:
		print(1, xmin, ymin)


import sys
INF = 10 ** 5

def solve():
	n = int(sys.stdin.readline())
	xl = yl = -INF
	xu = yu = INF
	for _ in range(n):
		(x, y, a, b, c, d) = map(int, sys.stdin.readline().split())
		if a == 0:
			xl = max(x, xl)
		if b == 0:
			yu = min(y, yu)
		if c == 0:
			xu = min(x, xu)
		if d == 0:
			yl = max(y, yl)
	if xl > xu or yl > yu:
		sys.stdout.write('0\n')
	else:
		sys.stdout.write(f'1 {xl} {yl}\n')

def main():
	q = int(input())
	for _ in range(q):
		solve()
main()


import sys
t = int(input())
for _ in range(t):
	n = int(sys.stdin.readline())
	(xMin, xMax, yMin, yMax) = (-100000, 100000, -100000, 100000)
	(x, y) = (0, 0)
	res = 1
	for i in range(n):
		(xi, yi, xMinus, yPlus, xPlus, yMinus) = map(int, sys.stdin.readline().split())
		if xMinus == 0:
			xMin = max(xi, xMin)
		if xPlus == 0:
			xMax = min(xi, xMax)
		if yMinus == 0:
			yMin = max(yi, yMin)
		if yPlus == 0:
			yMax = min(yi, yMax)
	if xMin <= xMax and yMin <= yMax:
		print(1, xMin, yMin)
	else:
		print(0)


from sys import stdin, stdout
input = stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	data = []
	for i in range(n):
		data.append([int(x) for x in input().split()])
	y_low = -10 ** 5
	y_high = 10 ** 5
	x_low = -10 ** 5
	x_high = 10 ** 5
	vals = sorted(data, key=lambda x: x[1], reverse=True)
	ans = 1
	for i in vals:
		if y_low <= i[1] <= y_high:
			if i[3] == 0 and i[5] == 0:
				y_low = y_high = i[1]
			elif i[3] == 0:
				y_high = i[1]
			elif i[5] == 0:
				y_low = i[1]
		elif i[3] == 0 and i[5] == 0:
			ans = 0
			break
		elif i[3] == 0:
			if i[1] < y_low:
				ans = 0
				break
		elif i[5] == 0:
			if i[1] > y_high:
				ans = 0
				break
	if not ans:
		print(ans)
		continue
	vals = sorted(data, key=lambda x: x[0], reverse=True)
	ans = 1
	for i in vals:
		if x_low <= i[0] <= x_high:
			if i[2] == 0 and i[4] == 0:
				x_low = x_high = i[0]
			elif i[2] == 0:
				x_low = i[0]
			elif i[4] == 0:
				x_high = i[0]
		elif i[2] == 0 and i[4] == 0:
			ans = 0
			break
		elif i[2] == 0:
			if i[0] > x_high:
				ans = 0
				break
		elif i[4] == 0:
			if i[0] < x_low:
				ans = 0
				break
	if not ans:
		print(ans)
		continue
	print(1, x_low, y_low)


t = int(input().strip())
for i in range(t):
	n = int(input().strip())
	(x_left, x_right, y_down, y_up) = (-100000, 100000, -100000, 100000)
	has = True
	for i in range(n):
		(cur_x, cur_y, left, up, right, down) = map(int, input().strip().split())
		(x1_left, x1_right, y1_down, y1_up) = (0, 0, 0, 0)
		if left == 1:
			x1_left = -100000
		else:
			x1_left = cur_x
		if right == 1:
			x1_right = 100000
		else:
			x1_right = cur_x
		if up == 1:
			y1_up = 100000
		else:
			y1_up = cur_y
		if down == 1:
			y1_down = -100000
		else:
			y1_down = cur_y
		if x1_left > x_right:
			has = False
		else:
			x_right = min(x1_right, x_right)
		if x1_right < x_left:
			has = False
		else:
			x_left = max(x1_left, x_left)
		if y1_down > y_up:
			has = False
		else:
			y_up = min(y_up, y1_up)
		if y1_up < y_down:
			has = False
		else:
			y_down = max(y_down, y1_down)
	if has:
		print(1, x_left, y_down)
	else:
		print(0)


import os
import math
import operator
import sys
from collections import defaultdict
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		n = int(input())
		matrix = []
		for i in range(n):
			lis = list(map(int, input().split()))
			matrix.append(lis)
		(minx, maxx) = (-10 ** 5, 10 ** 5)
		(miny, maxy) = (-10 ** 5, 10 ** 5)
		counter = 0
		for i in range(n):
			(mnx, mxx, mny, mxy) = (0, 0, 0, 0)
			x = matrix[i][0]
			y = matrix[i][1]
			if matrix[i][2] == 0:
				mnx = x
			else:
				mnx = -10 ** 5
			if matrix[i][3] == 0:
				mxy = y
			else:
				mxy = 10 ** 5
			if matrix[i][4] == 0:
				mxx = x
			else:
				mxx = 10 ** 5
			if matrix[i][5] == 0:
				mny = y
			else:
				mny = -10 ** 5
			if (mxx < minx or mnx > maxx) or (mxy < miny or mny > maxy):
				counter = 1
				break
			else:
				minx = max(minx, mnx)
				maxx = min(maxx, mxx)
				miny = max(miny, mny)
				maxy = min(maxy, mxy)
		if counter == 1:
			print(0)
		else:
			print(1, minx, miny)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import time
start_time = time.time()
import collections as col
import math, string
from functools import reduce

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7

def solve():
	N = getInt()
	(minx, maxx, miny, maxy) = (-10 ** 5, 10 ** 5, -10 ** 5, 10 ** 5)
	for n in range(N):
		(x, y, f1, f2, f3, f4) = getInts()
		if not f1:
			minx = max(x, minx)
		if not f2:
			maxy = min(y, maxy)
		if not f3:
			maxx = min(x, maxx)
		if not f4:
			miny = max(y, miny)
	if minx > maxx or miny > maxy:
		print(0)
		return
	print(1, minx, miny)
	return
for _ in range(getInt()):
	solve()


q = int(input())
rng = range
intt = int
maax = max
minn = min
for _ in rng(q):
	n = intt(input())
	maxx = maxy = 100000
	minx = miny = -100000
	for _ in rng(n):
		(x, y, l, u, r, b) = [intt(x) for x in input().split()]
		if not l:
			minx = maax(x, minx)
		if not u:
			maxy = minn(y, maxy)
		if not r:
			maxx = minn(x, maxx)
		if not b:
			miny = maax(y, miny)
	if minx <= maxx and miny <= maxy:
		print('1', minx, miny)
	else:
		print(0)


q = int(input())
for i in range(q):
	n = int(input())
	l = []
	x = [-10 ** 5, 10 ** 5]
	y = [-10 ** 5, 10 ** 5]
	for j in range(n):
		a = input().split()
		l.append(a)
		if int(l[j][2]) == 0:
			if x[0] < int(l[j][0]):
				x[0] = int(l[j][0])
		if int(l[j][3]) == 0:
			if y[1] > int(l[j][1]):
				y[1] = int(l[j][1])
		if int(l[j][4]) == 0:
			if x[1] > int(l[j][0]):
				x[1] = int(l[j][0])
		if int(l[j][5]) == 0:
			if y[0] < int(l[j][1]):
				y[0] = int(l[j][1])
	if x[0] > x[1] or y[0] > y[1]:
		print(0)
	elif x[0] == x[1] and y[0] == y[1]:
		z = ['1', str(x[0]), str(y[0])]
		print(' '.join(z))
	elif x[0] <= x[1] and y[0] <= y[1]:
		z = ['1', str(x[0]), str(y[0])]
		print(' '.join(z))


q = int(input())
for _ in range(q):
	n = int(input())
	r = []
	(max_x, min_x) = (10 ** 5, -10 ** 5)
	(max_y, min_y) = (10 ** 5, -10 ** 5)
	for i in range(n):
		t = [int(x) for x in input().split()]
		if t[2] == 0:
			min_x = max(min_x, t[0])
		if t[3] == 0:
			max_y = min(max_y, t[1])
		if t[4] == 0:
			max_x = min(max_x, t[0])
		if t[5] == 0:
			min_y = max(min_y, t[1])
	if min_x <= max_x and min_y <= max_y:
		print(1, min_x, min_y)
	else:
		print(0)


t = int(input())
for i in range(t):
	n = int(input())
	minx = -100000
	maxx = 100000
	miny = -100000
	maxy = 100000
	for i in range(n):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		if f1 == 0:
			if minx < x:
				minx = x
		if f2 == 0:
			if maxy > y:
				maxy = y
		if f3 == 0:
			if maxx > x:
				maxx = x
		if f4 == 0:
			if miny < y:
				miny = y
	if minx > maxx or miny > maxy:
		print(0)
	else:
		print(1, minx, miny)


for _ in range(int(input())):
	px = [-10 ** 5, 10 ** 5]
	py = [-10 ** 5, 10 ** 5]
	n = int(input())
	for i in range(n):
		(x, y, a, b, c, d) = [int(i) for i in input().split()]
		if not a:
			px[0] = max(px[0], x)
		if not b:
			py[1] = min(py[1], y)
		if not c:
			px[1] = min(px[1], x)
		if not d:
			py[0] = max(py[0], y)
	if px[0] > px[1] or py[0] > py[1]:
		print(0)
	else:
		print(1, px[0], py[0])


q = int(input())
for _ in range(q):
	xmin = int(-100000.0)
	xmax = int(100000.0)
	ymin = int(-100000.0)
	ymax = int(100000.0)
	n = int(input())
	for i in range(n):
		(x, y, d, c, b, a) = map(int, input().split(' '))
		if not a:
			ymin = max(ymin, y)
		if not b:
			xmax = min(xmax, x)
		if not c:
			ymax = min(ymax, y)
		if not d:
			xmin = max(xmin, x)
	if xmin > xmax or ymin > ymax:
		print(0)
	else:
		print('1 %i %i' % (xmin, ymin))


n = int(input())
for i in range(1, n + 1):
	minX = -100000
	maxX = 100000
	minY = -100000
	maxY = 100000
	q = int(input())
	for j in range(1, q + 1):
		(x, y, fi1, fi2, fi3, fi4) = [int(x) for x in input().split(' ')]
		if fi1 == 0:
			minX = max(minX, x)
		if fi2 == 0:
			maxY = min(y, maxY)
		if fi3 == 0:
			maxX = min(maxX, x)
		if fi4 == 0:
			minY = max(minY, y)
	if minX <= maxX and minY <= maxY:
		print(1, minX, minY, sep=' ')
	else:
		print(0)


import sys

def solve(robots):
	l = u = -100000
	r = d = 100000
	for robot in robots:
		if robot['mov'][0] == 0:
			l = max(l, robot['pos'][0])
		if robot['mov'][1] == 0:
			d = min(d, robot['pos'][1])
		if robot['mov'][2] == 0:
			r = min(r, robot['pos'][0])
		if robot['mov'][3] == 0:
			u = max(u, robot['pos'][1])
	if l <= r and u <= d:
		return [l, u]
	return []
for i in range(int(sys.stdin.readline())):
	n_robots = int(sys.stdin.readline())
	robots = []
	for _ in range(n_robots):
		(x, y, l, d, r, u) = map(int, sys.stdin.readline().split())
		robots.append({'pos': [x, y], 'mov': [l, d, r, u]})
	sol = solve(robots)
	sol = list(map(str, sol)) if sol else []
	if sol:
		print(' '.join(['1'] + sol))
	else:
		print(0)


q = int(input())
res = ''
for i in range(q):
	n = int(input())
	(minx, maxx) = (-100000, 100000)
	(miny, maxy) = (-100000, 100000)
	for j in range(n):
		(x, y, left, up, right, down) = [int(x) for x in input().split(' ')]
		if not left:
			minx = max(x, minx)
		if not up:
			maxy = min(y, maxy)
		if not right:
			maxx = min(x, maxx)
		if not down:
			miny = max(y, miny)
	if minx <= maxx and miny <= maxy:
		res += f'1 {minx} {miny}\n'
	else:
		res += '0\n'
print(res)


def main():
	tc = int(input())
	while tc > 0:
		tc -= 1
		(X, Y) = ([], [])
		n = int(input())
		for i in range(n):
			line = input().split()
			x = int(line[0])
			y = int(line[1])
			lo_x = -100000
			hi_x = 100000
			lo_y = -100000
			hi_y = 100000
			for j in range(2, 6):
				t = int(line[j])
				if t == 0:
					if j == 2:
						lo_x = x
					if j == 3:
						hi_y = y
					if j == 4:
						hi_x = x
					if j == 5:
						lo_y = y
			X.append((lo_x, hi_x))
			Y.append((lo_y, hi_y))
		L = -100000
		R = 100000
		D = -100000
		U = 100000
		for s in X:
			L = max(L, s[0])
			R = min(R, s[1])
		for s in Y:
			D = max(D, s[0])
			U = min(U, s[1])
		if L <= R and D <= U:
			print('1 ' + str(L) + ' ' + str(D))
		else:
			print('0')
main()


from sys import stdin
M = 10 ** 5

def solve(points):
	(min_x, min_y, max_x, max_y) = (-M, -M, M, M)
	for p in points:
		(x, y, f1, f2, f3, f4) = p
		if not f1:
			min_x = max(x, min_x)
		if not f3:
			max_x = min(x, max_x)
		if not f4:
			min_y = max(min_y, y)
		if not f2:
			max_y = min(max_y, y)
	if min_x <= max_x and min_y <= max_y:
		print(1, min_x, min_y)
	else:
		print(0)
q = int(stdin.readline().strip())
for _ in range(q):
	n = int(stdin.readline().strip())
	points = []
	for _ in range(n):
		points.append([int(i) for i in stdin.readline().strip().split()])
	solve(points)


def main():
	q = int(input())
	for i in range(q):
		n = int(input())
		l_x = -10 ** 5
		r_x = 10 ** 5
		l_y = -10 ** 5
		r_y = 10 ** 5
		flag = True
		for i in range(n):
			(x, y, f1, f2, f3, f4) = map(int, input().split())
			if flag:
				if f1 == f3 == 0:
					if not (x >= l_x and x <= r_x):
						flag = False
					else:
						l_x = x
						r_x = x
				elif f1 == 1 and f3 == 0:
					r_x = min(x, r_x)
				elif f1 == 0 and f3 == 1:
					l_x = max(x, l_x)
				if f2 == f4 == 0:
					if not (y >= l_y and y <= r_y):
						flag = False
					else:
						l_y = y
						r_y = y
				elif f2 == 1 and f4 == 0:
					l_y = max(y, l_y)
				elif f2 == 0 and f4 == 1:
					r_y = min(y, r_y)
				if l_x > r_x or l_y > r_y:
					flag = False
		if flag:
			print(1, l_x, l_y)
		else:
			print(0)
main()


import sys

def main():
	N = int(sys.stdin.readline().strip())
	for _ in range(N):
		(n,) = [int(x) for x in sys.stdin.readline().strip().split()]
		minx = -100000
		maxx = 100000
		miny = -100000
		maxy = 100000
		for _ in range(n):
			(x, y, f1, f2, f3, f4) = [int(x) for x in sys.stdin.readline().split()]
			if f1 == 0:
				minx = max(minx, x)
			if f3 == 0:
				maxx = min(maxx, x)
			if f4 == 0:
				miny = max(miny, y)
			if f2 == 0:
				maxy = min(maxy, y)
		if minx > maxx or miny > maxy:
			print(0)
		else:
			print(1, minx, miny)
main()


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline())
	x1 = y1 = -10 ** 5
	y2 = x2 = 10 ** 5
	for i in range(n):
		a = [0] + list(map(int, sys.stdin.readline().split()))
		if a[3] == 0:
			x1 = max(a[1], x1)
		if a[4] == 0:
			y2 = min(a[2], y2)
		if a[5] == 0:
			x2 = min(a[1], x2)
		if a[6] == 0:
			y1 = max(a[2], y1)
	if x1 <= x2 and y1 <= y2:
		print(1, x1, y1)
	else:
		print(0)


for i in range(int(input())):
	n = int(input())
	xl = -100000
	xr = 100000
	yd = -100000
	yu = 100000
	flag = True
	for j in range(n):
		(x, y, a, b, c, d) = map(int, input().split())
		if not a:
			if x > xl:
				xl = x
		if not b:
			if y < yu:
				yu = y
		if not c:
			if x < xr:
				xr = x
		if not d:
			if y > yd:
				yd = y
		if xr < xl or yd > yu:
			flag = False
	if not flag:
		print(0)
	else:
		print(1, xl, yd)


import atexit
import io
import sys
MAXC = int(100000.0)
t = int(input())
for i in range(t):
	(maxx, maxy, minx, miny) = (MAXC, MAXC, -MAXC, -MAXC)
	for q in range(int(input())):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		if not f1:
			minx = max(minx, x)
		if not f2:
			maxy = min(maxy, y)
		if not f3:
			maxx = min(maxx, x)
		if not f4:
			miny = max(miny, y)
	if minx <= maxx and miny <= maxy:
		print(1, minx, miny)
	else:
		print('0')


q = int(input())
for i in range(q):
	n = int(input())
	xl = -100000
	xh = 100000
	yl = -100000
	yh = 100000
	for j in range(n):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		if f1 == 0:
			if x > xl:
				xl = x
		if f2 == 0:
			if y < yh:
				yh = y
		if f3 == 0:
			if x < xh:
				xh = x
		if f4 == 0:
			if y > yl:
				yl = y
	if xh - xl < 0 or yh - yl < 0:
		print(0)
	else:
		print(1, xl, yl)


from sys import stdin, stdout
readline = stdin.readline
write = stdout.write
q = int(readline())
for query in range(q):
	n = int(readline())
	(x1, y1, x2, y2) = (-100000.0, -100000.0, 100000.0, 100000.0)
	for i in range(n):
		(x, y, a, b, c, d) = map(int, readline().split())
		if not a:
			x1 = max(x1, x)
		if not b:
			y2 = min(y2, y)
		if not c:
			x2 = min(x2, x)
		if not d:
			y1 = max(y1, y)
	if x2 < x1 or y2 < y1:
		print(0)
	else:
		print(1, int(x1), int(y1))


t = 1
t = int(input())
while t:
	t -= 1
	n = int(input())
	xrange = [-float('inf'), float('inf')]
	yrange = [-float('inf'), float('inf')]
	for _ in range(n):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		if not f1:
			xrange[0] = max(xrange[0], x)
		if not f2:
			yrange[1] = min(yrange[1], y)
		if not f3:
			xrange[1] = min(xrange[1], x)
		if not f4:
			yrange[0] = max(yrange[0], y)
	if xrange[1] < xrange[0] or yrange[1] < yrange[0]:
		print(0)
	else:
		print(1, max(-10 ** 5, xrange[0]), max(-10 ** 5, yrange[0]))


t = int(input())
for _ in range(t):
	n = int(input())
	(minX, maxX) = (int(-100000.0), int(100000.0))
	(minY, maxY) = (int(-100000.0), int(100000.0))
	for i in range(n):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		if f1 == 0:
			minX = max(minX, x)
		if f3 == 0:
			maxX = min(maxX, x)
		if f2 == 0:
			maxY = min(maxY, y)
		if f4 == 0:
			minY = max(minY, y)
	if minX > maxX or minY > maxY:
		print(0)
	else:
		print(1, minX, minY)


from __future__ import division, print_function
import math
import os
import sys
from fractions import *
from sys import *
from decimal import *
from io import BytesIO, IOBase
from itertools import *
from collections import *
M = 10 ** 9 + 7
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def fsep():
	return map(float, inp().split())

def inpu():
	return int(inp())

def regularbracket(t):
	p = 0
	for i in t:
		if i == '(':
			p += 1
		else:
			p -= 1
		if p < 0:
			return False
	else:
		if p > 0:
			return False
		else:
			return True

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] <= key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def reverse1(string):
	pp = ''
	for i in string[::-1]:
		pp += i
	if pp == string:
		return True
	return False

def reverse2(list1):
	l = []
	for i in list1[::-1]:
		l.append(i)
	if l == list1:
		return True
	return False

def mex(list1):
	p = max(list1) + 1
	for i in range(len(list1)):
		if list1[i] != i:
			p = i
			break
	return p

def sumofdigits(n):
	n = str(n)
	s1 = 0
	for i in n:
		s1 += int(i)
	return s1

def perfect_square(n):
	s = math.sqrt(n)
	if s == int(s):
		return True
	return False

def roman_number(x):
	if x > 15999:
		return
	value = [5000, 4000, 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
	symbol = ['F', 'MF', 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
	roman = ''
	i = 0
	while x > 0:
		div = x // value[i]
		x = x % value[i]
		while div:
			roman += symbol[i]
			div -= 1
		i += 1
	return roman

def soretd(s):
	for i in range(1, len(s)):
		if s[i - 1] > s[i]:
			return False
	return True

def countRhombi(h, w):
	ct = 0
	for i in range(2, h + 1, 2):
		for j in range(2, w + 1, 2):
			ct += (h - i + 1) * (w - j + 1)
	return ct

def countrhombi2(h, w):
	return h * h // 4 * (w * w // 4)

def binpow(a, b):
	if b == 0:
		return 1
	else:
		res = binpow(a, b // 2)
	if b % 2 != 0:
		return res * res * a
	else:
		return res * res

def binpowmodulus(a, b, m):
	a %= m
	res = 1
	while b > 0:
		if b & 1:
			res = res * a % m
		a = a * a % m
		b >>= 1
	return res

def coprime_to_n(n):
	result = n
	i = 2
	while i * i <= n:
		if n % i == 0:
			while n % i == 0:
				n //= i
			result -= result // i
		i += 1
	if n > 1:
		result -= result // n
	return result

def prime(x):
	if x == 1:
		return False
	else:
		for i in range(2, int(math.sqrt(x)) + 1):
			if x % i == 0:
				return False
		else:
			return True

def luckynumwithequalnumberoffourandseven(x, n, a):
	if x >= n and str(x).count('4') == str(x).count('7'):
		a.append(x)
	elif x < 1000000000000.0:
		luckynumwithequalnumberoffourandseven(x * 10 + 4, n, a)
		luckynumwithequalnumberoffourandseven(x * 10 + 7, n, a)
	return a

def luckynum(x, l, r, a):
	if x >= l and x <= r:
		a.append(x)
	if x > r:
		a.append(x)
		return a
	if x < 10000000000.0:
		luckynum(x * 10 + 4, l, r, a)
		luckynum(x * 10 + 7, l, r, a)
	return a

def luckynuber(x, n, a):
	p = set(str(x))
	if len(p) <= 2:
		a.append(x)
	if x < n:
		luckynuber(x + 1, n, a)
	return a

def interact(type, x):
	if type == 'r':
		inp = input()
		return inp.strip()
	else:
		print(x, flush=True)

def findTrailingZeros(n):
	count = 0
	while n >= 5:
		n //= 5
		count += n
	return count

def mergeSort(arr):
	if len(arr) > 1:
		mid = len(arr) // 2
		L = arr[:mid]
		R = arr[mid:]
		mergeSort(L)
		mergeSort(R)
		i = j = k = 0
		while i < len(L) and j < len(R):
			if L[i] < R[j]:
				arr[k] = L[i]
				i += 1
			else:
				arr[k] = R[j]
				j += 1
			k += 1
		while i < len(L):
			arr[k] = L[i]
			i += 1
			k += 1
		while j < len(R):
			arr[k] = R[j]
			j += 1
			k += 1
res = set()

def solven(p, l, a, b, n):
	if p > n or l > 10:
		return
	if p > 0:
		res.add(p)
	solven(p * 10 + a, l + 1, a, b, n)
	solven(p * 10 + b, l + 1, a, b, n)

def subsetsUtil(A, subset, index, d):
	print(*subset)
	s = sum(subset)
	d.append(s)
	for i in range(index, len(A)):
		subset.append(A[i])
		subsetsUtil(A, subset, i + 1, d)
		subset.pop(-1)
	return d

def subsetSums(arr, l, r, d, sum=0):
	if l > r:
		d.append(sum)
		return
	subsetSums(arr, l + 1, r, d, sum + arr[l])
	subsetSums(arr, l + 1, r, d, sum)
	return d

def print_factors(x):
	factors = []
	for i in range(1, x + 1):
		if x % i == 0:
			factors.append(i)
	return factors

def calc(X, d, ans, D):
	if len(X) == 0:
		return
	i = X.index(max(X))
	ans[D[max(X)]] = d
	Y = X[:i]
	Z = X[i + 1:]
	calc(Y, d + 1, ans, D)
	calc(Z, d + 1, ans, D)

def factorization(n, l):
	c = n
	if prime(n) == True:
		l.append(n)
		return l
	for i in range(2, c):
		if n == 1:
			break
		while n % i == 0:
			l.append(i)
			n = n // i
	return l

def good(b):
	l = []
	i = 0
	while len(b) != 0:
		if b[i] < b[len(b) - 1 - i]:
			l.append(b[i])
			b.remove(b[i])
		else:
			l.append(b[len(b) - 1 - i])
			b.remove(b[len(b) - 1 - i])
	if l == sorted(l):
		return True
	return False

def generate(st, s):
	if len(s) == 0:
		return
	if s not in st:
		st.add(s)
		for i in range(len(s)):
			t = list(s).copy()
			t.remove(s[i])
			t = ''.join(t)
			generate(st, t)
	return

def largestincreasingsubsequence(A):
	l = [1] * len(A)
	sub = []
	for i in range(1, len(l)):
		for k in range(i):
			if A[k] < A[i]:
				sub.append(l[k])
		l[i] = 1 + max(sub, default=0)
	return max(l, default=0)

def findOR(nums, N):
	prefix_sum = 0
	result = 0
	for i in range(N):
		result |= nums[i]
		prefix_sum += nums[i]
		result |= prefix_sum
	return result

def OR(a, n):
	ans = a[0]
	for i in range(1, n):
		ans |= a[i]
	return ans

def main():
	inf = 100000
	for _ in range(inpu()):
		(x1, y1, x2, y2) = (-inf, -inf, inf, inf)
		for _ in range(int(input())):
			(x, y, f1, f2, f3, f4) = sep()
			if not f1:
				x1 = max(x1, x)
			if not f2:
				y2 = min(y2, y)
			if not f3:
				x2 = min(x2, x)
			if not f4:
				y1 = max(y1, y)
		if x1 > x2 or y1 > y2:
			print(0)
		else:
			print(1, x1, y1)
main()


N = int(input())
lst = []
for k in range(N):
	n = int(input())
	a = []
	for j in range(n):
		L = list(map(int, input().split()))
		a.append(L)
	lst.append((n, a))
for couple in lst:
	top = [100000, 100000]
	bot = [-100000, -100000]
	(n, b) = couple
	for a in b:
		x = a[0]
		y = a[1]
		if a[2] == 0 and x > bot[0]:
			bot[0] = x
		if a[3] == 0 and y < top[1]:
			top[1] = y
		if a[4] == 0 and x < top[0]:
			top[0] = x
		if a[5] == 0 and y > bot[1]:
			bot[1] = y
	if top[0] >= bot[0] and top[1] >= bot[1]:
		print(1, bot[0], bot[1])
	else:
		print(0)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(left, down, right, up) = (-10 ** 5, -10 ** 5, 10 ** 5, 10 ** 5)
	res = 1
	for _ in range(int(input())):
		(x, y, l, u, r, d) = map(int, input().split())
		if res == 1:
			if u == 1 and d == 0:
				if up < y:
					res = 0
				else:
					down = max(down, y)
			if u == 0 and d == 1:
				if down > y:
					res = 0
				else:
					up = min(up, y)
			if u == 0 and d == 0:
				if down <= y and y <= up:
					up = down = y
				else:
					res = 0
			if r == 1 and l == 0:
				if right < x:
					res = 0
				else:
					left = max(left, x)
			if r == 0 and l == 1:
				if left > x:
					res = 0
				else:
					right = min(right, x)
			if r == 0 and l == 0:
				if left <= x and x <= right:
					left = right = x
				else:
					res = 0
	if res == 0:
		print(0)
	else:
		print(*[1, left, down])


q = int(input())
for _ in range(q):
	n = int(input())
	maxi1 = -10 ** 5
	mini1 = 10 ** 5
	maxi2 = -10 ** 5
	mini2 = 10 ** 5
	stack = []
	flag = 0
	for i in range(n):
		l = list(map(int, input().split()))
		(x_min, x_max, y_min, y_max) = (l[0], l[0], l[1], l[1])
		if l[2] == 1:
			x_min = -10 ** 5
		if l[3] == 1:
			y_max = 10 ** 5
		if l[4] == 1:
			x_max = 10 ** 5
		if l[5] == 1:
			y_min = -10 ** 5
		if i != 0:
			if (mini1 <= x_min <= maxi1 or x_min <= mini1 <= x_max) and (mini2 <= y_min <= maxi2 or y_min <= mini2 <= y_max):
				mini1 = max(x_min, mini1)
				mini2 = max(y_min, mini2)
				maxi1 = min(x_max, maxi1)
				maxi2 = min(y_max, maxi2)
			else:
				flag = 1
		else:
			mini1 = min(x_min, mini1)
			mini2 = min(y_min, mini2)
			maxi1 = max(x_max, maxi1)
			maxi2 = max(y_max, maxi2)
	if flag == 1:
		print(0)
	else:
		print(1, mini1, mini2)


n = int(input())
m = 10 ** 5
for i in range(n):
	p = int(input())
	mnx = -m
	mny = -m
	mxx = m
	mxy = m
	for i in range(p):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		if f1 == 0:
			mnx = max(mnx, x)
		if f2 == 0:
			mxy = min(mxy, y)
		if f3 == 0:
			mxx = min(mxx, x)
		if f4 == 0:
			mny = max(mny, y)
	if mnx <= mxx and mny <= mxy:
		print(1, mnx, mny)
	else:
		print(0)


q = int(input())
for _ in range(q):
	n = int(input())
	maxX = maxY = 10 ** 5
	minX = minY = -10 ** 5
	for i in range(n):
		(x, y, *rest) = map(int, input().split())
		if rest[0] == 0:
			minX = max(minX, x)
		if rest[1] == 0:
			maxY = min(maxY, y)
		if rest[2] == 0:
			maxX = min(maxX, x)
		if rest[3] == 0:
			minY = max(minY, y)
	if minX > maxX or minY > maxY:
		print(0)
	else:
		print(1, minX, minY)


def find_pos():
	min_range_x = -10 ** 5
	max_range_x = 10 ** 5
	min_range_y = -10 ** 5
	max_range_y = 10 ** 5
	for robot in robots:
		robot_x = robot[0]
		robot_y = robot[1]
		if robot[2] == 0:
			if robot_x > min_range_x:
				min_range_x = robot_x
		if robot[4] == 0:
			if robot_x < max_range_x:
				max_range_x = robot_x
		if robot[5] == 0:
			if robot_y > min_range_y:
				min_range_y = robot_y
		if robot[3] == 0:
			if robot_y < max_range_y:
				max_range_y = robot_y
	if max_range_x < min_range_x or max_range_y < min_range_y:
		return (0, 0)
	else:
		return (1, min_range_x, min_range_y)
q = int(input())
for _ in range(q):
	n = int(input())
	robots = []
	for __ in range(n):
		robots.append(list(map(int, input().split())))
	value = find_pos()
	if value[0] == 1:
		print(value[0], value[1], value[2])
	else:
		print(0)


t = int(input())
for _ in range(t):
	n = int(input())
	ymx = 10 ** 5
	ymn = -ymx
	xmx = ymx
	xmn = ymn
	for _ in range(n):
		(x, y, a, b, c, d) = map(int, input().split())
		if a == 0:
			xmn = max(xmn, x)
		if c == 0:
			xmx = min(xmx, x)
		if d == 0:
			ymn = max(ymn, y)
		if b == 0:
			ymx = min(ymx, y)
	if xmx >= xmn and ymx >= ymn:
		print(1, xmn, ymn)
	else:
		print(0)


T = int(input())
for _ in range(T):
	n = int(input())
	pos = [0, 0, -100000, 100000, 100000, -100000]
	for _ in range(n):
		a = list(map(int, input().split()))
		if a[2] == 0:
			pos[2] = max(pos[2], a[0])
		if a[3] == 0:
			pos[3] = min(pos[3], a[1])
		if a[4] == 0:
			pos[4] = min(pos[4], a[0])
		if a[5] == 0:
			pos[5] = max(pos[5], a[1])
	if pos[2] <= pos[4] and pos[5] <= pos[3]:
		print(1, pos[2], pos[5])
	else:
		print(0)


from sys import stdin, stdout
input = stdin.readline
print = stdout.write
for _ in range(int(input())):
	n = int(input())
	maxx = 100000.0
	minx = -100000.0
	maxy = 100000.0
	miny = -100000.0
	for i in range(n):
		arr = list(map(int, input().split()))
		if not arr[2]:
			minx = max(arr[0], minx)
		if not arr[3]:
			maxy = min(arr[1], maxy)
		if not arr[4]:
			maxx = min(arr[0], maxx)
		if not arr[5]:
			miny = max(arr[1], miny)
	if maxx < minx or maxy < miny:
		print('0\n')
	else:
		print('1 %d %d\n' % (minx, miny))


from heapq import heappush, heappop
from collections import deque, Counter, defaultdict
import itertools
import sys
sys.setrecursionlimit(10 ** 6)

def MI():
	return map(int, input().split())

def I():
	return int(input())

def LI():
	return [int(i) for i in input().split()]
YN = ['YES', 'NO']
input = sys.stdin.readline
q = I()
for _ in range(q):
	ans = 0
	n = I()
	(xmin, ymin) = (-10 ** 5, -10 ** 5)
	(xmax, ymax) = (10 ** 5, 10 ** 5)
	(xf, yf) = (True, True)
	for i in range(n):
		(x, y, *a) = LI()
		if a[0] * a[2] == 1:
			pass
		elif a[0] == 1:
			xmax = min(xmax, x)
		elif a[2] == 1:
			xmin = max(xmin, x)
		else:
			if xmin <= x <= xmax:
				pass
			else:
				xf = False
			xmin = x
			xmax = x
		if a[1] * a[3] == 1:
			pass
		elif a[3] == 1:
			ymax = min(ymax, y)
		elif a[1] == 1:
			ymin = max(ymin, y)
		else:
			if ymin <= y <= ymax:
				pass
			else:
				yf = False
			ymin = y
			ymax = y
	if xmax >= xmin and ymax >= ymin and xf and yf:
		print(1, xmin, ymin)
	else:
		print(0)


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	r = [list(map(int, input().split())) for _ in range(n)]
	pos = [[r[0][0], r[0][1]], [r[0][0], r[0][1]]]
	if r[0][2]:
		pos[0][0] = -100000
	if r[0][4]:
		pos[1][0] = 100000
	if r[0][3]:
		pos[1][1] = 100000
	if r[0][5]:
		pos[0][1] = -100000
	for robot in r[1:]:
		robot_pos = ([robot[0], robot[1]], [robot[0], robot[1]])
		if robot[2]:
			robot_pos[0][0] = -100000
		if robot[4]:
			robot_pos[1][0] = 100000
		if robot[3]:
			robot_pos[1][1] = 100000
		if robot[5]:
			robot_pos[0][1] = -100000
		if robot_pos[1][0] < pos[0][0] or robot_pos[0][0] > pos[1][0] or robot_pos[1][1] < pos[0][1] or (robot_pos[0][1] > pos[1][1]):
			print(0)
			break
		else:
			pos[0][0] = max(robot_pos[0][0], pos[0][0])
			pos[0][1] = max(robot_pos[0][1], pos[0][1])
			pos[1][0] = min(robot_pos[1][0], pos[1][0])
			pos[1][1] = min(robot_pos[1][1], pos[1][1])
	else:
		print(1, pos[0][0], pos[0][1])


def f(robots):
	minx = -100000
	miny = -100000
	maxx = 1000000
	maxy = 1000000
	for r in robots:
		x = r[0]
		y = r[1]
		mx = my = -100000
		Mx = My = 1000000
		if r[2] == 0:
			mx = x
		if r[3] == 0:
			My = y
		if r[4] == 0:
			Mx = x
		if r[5] == 0:
			my = y
		if mx > minx:
			minx = mx
		if Mx < maxx:
			maxx = Mx
		if my > miny:
			miny = my
		if My < maxy:
			maxy = My
		if minx > maxx:
			return None
		if miny > maxy:
			return None
	return (minx, miny)
nq = int(input().strip())
for j in range(nq):
	nr = int(input().strip())
	robots = [None] * nr
	for i in range(nr):
		robots[i] = [int(x) for x in input().strip().split(' ')]
	res = f(robots)
	if res:
		print('1 ' + str(res[0]) + ' ' + str(res[1]))
	else:
		print('0')


from sys import stdin

def ii():
	return int(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def li():
	return list(mi())

def si():
	return stdin.readline()
for _ in range(ii()):
	f = 1
	r = u = 100000
	l = d = -100000
	for _ in range(ii()):
		(x, y, rt, n, b, up) = mi()
		if f:
			if not rt:
				l = max(l, x)
			if not n:
				u = min(y, u)
			if not b:
				r = min(r, x)
			if not up:
				d = max(y, d)
			if l > r or d > u:
				f = 0
	if f:
		print(f, l, d)
	else:
		print(f)


import sys
import math
import heapq
from collections import defaultdict, deque
from decimal import *

def R():
	return int(input())

def RM():
	return map(int, input().split())

def RL():
	return list(map(int, input().split()))
for _ in range(R()):
	n = R()
	xn = -10 ** 5
	xp = 10 ** 5
	yn = -10 ** 5
	yp = 10 ** 5
	xpos = True
	ypos = True
	for i in range(n):
		(x, y, l, u, r, d) = RM()
		movxn = x if l == 0 else -10 ** 5
		movxp = x if r == 0 else 10 ** 5
		movyn = y if d == 0 else -10 ** 5
		movyp = y if u == 0 else 10 ** 5
		xn = max(xn, movxn)
		xp = min(xp, movxp)
		yn = max(yn, movyn)
		yp = min(yp, movyp)
		if xn > xp:
			xpos = False
		if yn > yp:
			ypos = False
	if (xpos and ypos) == False:
		print(0)
	else:
		print(1, xn, yn)


t = int(input())
for i in range(t):
	n = int(input())
	m = []
	amin = -10 ** 5
	bmin = -10 ** 5
	amax = 10 ** 5
	bmax = 10 ** 5
	for i in range(n):
		[x, y, l, u, r, d] = list(map(int, input().split()))
		m.append([x, y, l, u, r, d])
	for i in m:
		if i[2] == 0:
			aamin = i[0]
		else:
			aamin = -10 ** 5
		if i[3] == 0:
			bbmax = i[1]
		else:
			bbmax = 10 ** 5
		if i[4] == 0:
			aamax = i[0]
		else:
			aamax = 10 ** 5
		if i[5] == 0:
			bbmin = i[1]
		else:
			bbmin = -10 ** 5
		if amin <= aamin:
			amin = aamin
		if bmin <= bbmin:
			bmin = bbmin
		if amax >= aamax:
			amax = aamax
		if bmax >= bbmax:
			bmax = bbmax
		if amin <= amax and bmin <= bmax:
			continue
		else:
			print(0)
			break
	else:
		print(1, amin, bmin)


from sys import stdin, stdout
import collections
Q = int(input())
for i in range(Q):
	N = int(input())
	data = []
	for j in range(N):
		arr = [int(x) for x in stdin.readline().split()]
		data.append(arr)
	x_r = [-100000, 100000]
	y_r = [-100000, 100000]
	flag = 0
	for j in range(N):
		robot = data[j]
		x_avail = [-100000, 100000]
		y_avail = [-100000, 100000]
		if robot[2] == 0:
			x_avail[0] = robot[0]
		if robot[4] == 0:
			x_avail[1] = robot[0]
		if robot[3] == 0:
			y_avail[1] = robot[1]
		if robot[5] == 0:
			y_avail[0] = robot[1]
		if x_avail[0] > x_r[1] or x_r[0] > x_avail[1]:
			flag = 1
			break
		if y_avail[0] > y_r[1] or y_r[0] > y_avail[1]:
			flag = 1
			break
		x_r[0] = max(x_r[0], x_avail[0])
		x_r[1] = min(x_r[1], x_avail[1])
		y_r[0] = max(y_r[0], y_avail[0])
		y_r[1] = min(y_r[1], y_avail[1])
	if flag == 1:
		print(0)
	else:
		print(1, x_r[0], y_r[0])


q = int(input())
for _ in range(q):
	n = int(input())
	x_min = -100000
	x_max = 100000
	y_min = -100000
	y_max = 100000
	possible = True
	for _ in range(n):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		if f1 == 0:
			x_min = max(x_min, x)
		if f2 == 0:
			y_max = min(y_max, y)
		if f3 == 0:
			x_max = min(x_max, x)
		if f4 == 0:
			y_min = max(y_min, y)
	if x_min <= x_max and y_min <= y_max:
		print('1 {} {}'.format(x_min, y_min))
	else:
		print('0')


import sys
input = sys.stdin.readline
q = int(input())
INF = 10 ** 5
for i in range(q):
	n = int(input())
	x1 = -INF
	x2 = INF
	y1 = -INF
	y2 = INF
	for j in range(n):
		(x, y, a, b, c, d) = map(int, input().split())
		if a == 0:
			x1 = max(x1, x)
		if b == 0:
			y2 = min(y2, y)
		if c == 0:
			x2 = min(x2, x)
		if d == 0:
			y1 = max(y1, y)
	if x1 > x2 or y1 > y2:
		print(0)
	else:
		print(1, x1, y1)


q = int(input())
for query in range(q):
	n = int(input())
	robos = {}
	for _ in range(n):
		robos[_] = list(map(int, input().split()))
	x1 = -100000
	x2 = 100000
	y1 = -100000
	y2 = 100000
	for elem in robos:
		unit = robos[elem]
		if unit[2] == 0:
			if x1 < unit[0]:
				x1 = unit[0]
		if unit[3] == 0:
			if y2 > unit[1]:
				y2 = unit[1]
		if unit[4] == 0:
			if x2 > unit[0]:
				x2 = unit[0]
		if unit[5] == 0:
			if y1 < unit[1]:
				y1 = unit[1]
	if x1 > x2 or y1 > y2:
		print(0)
	else:
		print(f'1 {x1} {y1}')


q = int(input())
for _ in range(q):
	n = int(input())
	x1 = -100000
	x2 = 100000
	y1 = 100000
	y2 = -100000
	for _ in range(n):
		(x, y, l, u, r, d) = map(int, input().split())
		if l == 0:
			x1 = max(x, x1)
		if u == 0:
			y1 = min(y, y1)
		if r == 0:
			x2 = min(x2, x)
		if d == 0:
			y2 = max(y2, y)
	if x2 - x1 >= 0 and y1 - y2 >= 0:
		print(1, x1, y2)
	else:
		print(0)


from sys import stdin, stdout
from math import gcd, sqrt, factorial, pi, inf
from collections import deque, defaultdict
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(str(x) + '\n')
lcm = lambda x, y: x * y // gcd(x, y)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 1 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 6 + 6
for _ in range(I()):
	n = I()
	up = left = -10 ** 5
	down = right = 10 ** 5
	for i in range(n):
		(*x,) = R()
		if not x[2]:
			up = max(up, x[0])
		if not x[4]:
			down = min(down, x[0])
		if not x[3]:
			right = min(right, x[1])
		if not x[5]:
			left = max(left, x[1])
	if left > right or up > down:
		print(0)
		continue
	print(1, up, left)


q = int(input())
while q:
	q -= 1
	(minx, miny, maxx, maxy) = (-100000.0, -100000.0, 100000.0, 100000.0)
	n = int(input())
	while n:
		n -= 1
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		if f1 == 0:
			minx = max(minx, x)
		if f2 == 0:
			maxy = min(maxy, y)
		if f3 == 0:
			maxx = min(maxx, x)
		if f4 == 0:
			miny = max(miny, y)
	if minx <= maxx and miny <= maxy:
		print(1, int(minx), int(miny))
	else:
		print(0)


def int_list():
	return [int(c) for c in input().split()]

def int1():
	return int(input())

def str_list():
	return [c for c in input().split()]

def str1():
	return input()
neg_bound = -100000
pos_bound = 100000
q = int1()
res = []
for i in range(q):
	n = int1()
	xbs = []
	ybs = []
	for j in range(n):
		params = int_list()
		neg_x = params[2]
		pos_y = params[3]
		pos_x = params[4]
		neg_y = params[5]
		curr_x = params[0]
		curr_y = params[1]
		low_x = curr_x if neg_x == 0 else neg_bound
		low_y = curr_y if neg_y == 0 else neg_bound
		high_x = curr_x if pos_x == 0 else pos_bound
		high_y = curr_y if pos_y == 0 else pos_bound
		xbs.append([low_x, high_x])
		ybs.append([low_y, high_y])
	xb_init = [neg_bound, pos_bound]
	yb_init = [neg_bound, pos_bound]
	no_solution = False
	for xb in xbs:
		if xb[0] > xb_init[1] or xb[1] < xb_init[0]:
			no_solution = True
			break
		else:
			xb_init[0] = xb[0] if xb[0] > xb_init[0] else xb_init[0]
			xb_init[1] = xb[1] if xb[1] < xb_init[1] else xb_init[1]
	for yb in ybs:
		if yb[0] > yb_init[1] or yb[1] < yb_init[0]:
			no_solution = True
			break
		else:
			yb_init[0] = yb[0] if yb[0] > yb_init[0] else yb_init[0]
			yb_init[1] = yb[1] if yb[1] < yb_init[1] else yb_init[1]
	if no_solution:
		res.append(0)
	else:
		s = '1 ' + str(xb_init[0]) + ' ' + str(yb_init[0])
		res.append(s)
for result in res:
	print(result)


q = int(input())
answer = [[] for i in range(q)]
for a in range(q):
	x = []
	y = []
	f1 = []
	f2 = []
	f3 = []
	f4 = []
	n = int(input())
	for i in range(n):
		(xi, yi, f1i, f2i, f3i, f4i) = map(int, input().split())
		x.append(xi)
		y.append(yi)
		f1.append(f1i)
		f2.append(f2i)
		f3.append(f3i)
		f4.append(f4i)
	maxx = 100000
	maxy = 100000
	minx = -100000
	miny = -100000
	for i in range(n):
		if f1[i] == 0:
			if x[i] > minx:
				minx = x[i]
		if f2[i] == 0:
			if y[i] < maxy:
				maxy = y[i]
		if f3[i] == 0:
			if x[i] < maxx:
				maxx = x[i]
		if f4[i] == 0:
			if y[i] > miny:
				miny = y[i]
	if maxy >= miny:
		if maxx >= minx:
			answer[a].append(1)
			answer[a].append(minx)
			answer[a].append(miny)
		else:
			answer[a].append(0)
			continue
	else:
		answer[a].append(0)
		continue
for i in range(q):
	print(*answer[i])


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
v = 10 ** 5
queries = int(input())
for q in range(queries):
	n = int(input())
	(scope_x, scope_y) = ([-v, v], [-v, v])
	f = 0
	for i in range(n):
		(x, y, f1, f2, f3, f4) = list(map(int, input().split()))
		(xmax, xmin) = (x, x)
		(ymax, ymin) = (y, y)
		if f1:
			xmin = -v
		if f2:
			ymax = v
		if f3:
			xmax = v
		if f4:
			ymin = -v
		(curscp_x, curscp_y) = ([xmin, xmax], [ymin, ymax])
		if scope_x[1] < curscp_x[0] or scope_x[0] > curscp_x[1]:
			f = 1
		else:
			scope_x[0] = max(scope_x[0], curscp_x[0])
			scope_x[1] = min(scope_x[1], curscp_x[1])
		if scope_y[1] < curscp_y[0] or scope_y[0] > curscp_y[1]:
			f = 1
		else:
			scope_y[0] = max(scope_y[0], curscp_y[0])
			scope_y[1] = min(scope_y[1], curscp_y[1])
	if f == 1:
		print(0)
	else:
		print(1, scope_x[0], scope_y[0])


for _ in range(int(input())):
	n = int(input())
	x_max = 100000.0
	x_min = -100000.0
	y_max = 100000.0
	y_min = -100000.0
	for i in range(n):
		(x1, y1, l, u, r, d) = map(int, input().split())
		if u == 0:
			if y1 < y_max:
				y_max = y1
		if d == 0:
			if y1 > y_min:
				y_min = y1
		if l == 0:
			if x1 > x_min:
				x_min = x1
		if r == 0:
			if x1 < x_max:
				x_max = x1
	if x_min > x_max or y_min > y_max:
		print(0)
	else:
		print(1, int(x_min), int(y_min))


from sys import stdin, stdout
from math import gcd, ceil, sqrt
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
tc = ii1()
for _ in range(tc):
	n = ii1()
	robo = []
	for i in range(n):
		robo.append(iia())
	hor_min = ver_min = -10 ** 5
	hor_max = ver_max = 10 ** 5
	robo.sort()
	for i in robo:
		if i[2] == 0:
			if hor_min <= i[0]:
				hor_min = i[0]
				if hor_max < hor_min:
					print(0)
					break
		if i[4] == 0:
			if hor_max >= i[0]:
				hor_max = i[0]
				if hor_max < hor_min:
					print(0)
					break
		if i[3] == 0:
			if ver_max >= i[1]:
				ver_max = i[1]
				if ver_max < ver_min:
					print(0)
					break
		if i[5] == 0:
			if ver_min <= i[1]:
				ver_min = i[1]
				if ver_max < ver_min:
					print(0)
					break
	else:
		print(1, hor_min, ver_min)


import sys
for _ in range(int(sys.stdin.readline())):
	(minx, maxx, miny, maxy) = (-100000, 100000, -100000, 100000)
	for i in range(int(sys.stdin.readline())):
		(x, y, f1, f2, f3, f4) = map(int, sys.stdin.readline().split())
		minx = max(x, minx) if f1 == 0 else minx
		maxx = min(maxx, x) if f3 == 0 else maxx
		maxy = min(maxy, y) if f2 == 0 else maxy
		miny = max(y, miny) if f4 == 0 else miny
	print(0) if minx > maxx or miny > maxy else print(1, minx, miny)


for _ in range(int(input())):
	n = int(input())
	l = d = -10 ** 5
	r = t = 10 ** 5
	for i in range(n):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		if f1 == 0:
			l = max(l, x)
		if f2 == 0:
			t = min(t, y)
		if f3 == 0:
			r = min(r, x)
		if f4 == 0:
			d = max(d, y)
	if l <= r and d <= t:
		print(1, l, d)
	else:
		print(0)


y = 10 ** 5
T = int(input())
for _ in range(T):
	x = [-y, -y, y, y]
	n = int(input())
	for _ in range(n):
		a = list(map(int, input().split()))
		if not a[2]:
			x[0] = max(x[0], a[0])
		if not a[3]:
			x[3] = min(x[3], a[1])
		if not a[4]:
			x[2] = min(x[2], a[0])
		if not a[5]:
			x[1] = max(x[1], a[1])
	if x[0] <= x[2] and x[1] <= x[3]:
		print(1, x[0], x[1])
	else:
		print(0)


for _ in range(int(input())):
	maxx = 100000
	maxy = 100000
	minx = -100000
	miny = -100000
	poss = True
	for i in range(int(input())):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		if f1 == 0:
			minx = max(minx, x)
		if f2 == 0:
			maxy = min(maxy, y)
		if f3 == 0:
			maxx = min(maxx, x)
		if f4 == 0:
			miny = max(miny, y)
	if minx <= maxx and miny <= maxy:
		print(1, minx, miny)
	else:
		print(0)


t = int(input())
for z in range(t):
	n = int(input())
	mg = 100000
	x_min = -mg
	y_min = -mg
	x_max = +mg
	y_max = +mg
	for i in range(n):
		(x, y, a, b, c, d) = map(int, input().split())
		if a == 0:
			x_min = max(x, x_min)
		if b == 0:
			y_max = min(y, y_max)
		if c == 0:
			x_max = min(x, x_max)
		if d == 0:
			y_min = max(y, y_min)
	if x_min <= x_max and y_min <= y_max:
		print(1, x_min, y_min)
	else:
		print(0)


for q in range(int(input())):
	k = int(input())
	f = []
	left = -100000
	down = -100000
	right = 100000
	up = 100000
	for t in range(k):
		f.append(tuple(map(int, input().split())))
	for n in range(k):
		if f[n][2] == 1 and f[n][3] == 1 and (f[n][4] == 1) and (f[n][5] == 1):
			continue
		else:
			if f[n][2] == 0 and f[n][0] > left:
				left = f[n][0]
			if f[n][3] == 0 and f[n][1] < up:
				up = f[n][1]
			if f[n][4] == 0 and f[n][0] < right:
				right = f[n][0]
			if f[n][5] == 0 and f[n][1] > down:
				down = f[n][1]
	if left <= right and down <= up:
		print('1 ' + str(left) + ' ' + str(down))
	else:
		print(0)


import sys
t = int(input())
for i in range(t):
	n = int(input())
	b = []
	for i in range(n):
		li = [int(i) for i in input().split()]
		b.append(li)
	l = []
	r = []
	u = []
	d = []
	for li in b:
		if li[2] == 0:
			l.append(li[0])
		if li[3] == 0:
			d.append(li[1])
		if li[4] == 0:
			r.append(li[0])
		if li[5] == 0:
			u.append(li[1])
	l.sort(reverse=True)
	r.sort()
	u.sort(reverse=True)
	d.sort()
	if len(l) == 0:
		l.insert(0, -100000)
	if len(u) == 0:
		u.insert(0, -100000)
	if len(r) == 0:
		r.insert(0, 100000)
	if len(d) == 0:
		d.insert(0, 100000)
	if u[0] > d[0] or l[0] > r[0]:
		print(0)
		continue
	print(1, l[0], u[0])


q = int(input())
for _ in range(q):
	n = int(input())
	minx = -100000
	maxx = 100000
	miny = -100000
	maxy = 100000
	(x, y) = (-100000, -100000)
	for i in range(n):
		xy = list(map(int, input().split()))
		if xy[2] == 0:
			minx = max(xy[0], minx)
		if xy[4] == 0:
			maxx = min(maxx, xy[0])
		if xy[3] == 0:
			maxy = min(maxy, xy[1])
		if xy[5] == 0:
			miny = max(xy[1], miny)
	if minx > maxx:
		print(0)
		continue
	else:
		x = minx
	if miny > maxy:
		print(0)
		continue
	else:
		y = miny
	print(1, x, y)