$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
Tags: Implementation

Starter code:

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


for i in range(int(input())):
	n = int(input())
	ans = []
	(x1, y1, x2, y2) = (-1000000000, -1000000000, 1000000000, 1000000000)
	for i in range(n):
		ans.append(list(map(int, input().split())))
	for i in range(n):
		k = ans[i]
		if k[2] == 0:
			if k[0] > x1:
				x1 = k[0]
		if k[3] == 0:
			if k[1] < y2:
				y2 = k[1]
		if k[4] == 0:
			if k[0] < x2:
				x2 = k[0]
		if k[5] == 0:
			if k[1] > y1:
				y1 = k[1]
	ans1 = x1
	ans2 = y1
	if x1 == -1000000000 and x2 == 1000000000:
		ans1 = 0
	elif x1 == -1000000000:
		ans1 = x2
	elif x2 == 1000000000:
		ans1 = x1
	if y1 == -1000000000 and y2 == 1000000000:
		ans2 = 0
	elif y1 == -1000000000:
		ans2 = y2
	elif y2 == 1000000000:
		ans2 = y1
	if x1 > x2:
		print(0)
	elif y1 > y2:
		print(0)
	else:
		print(1, ans1, ans2)


for _ in range(int(input())):
	n = int(input())
	xl = -100000
	xr = 100000
	yup = 100000
	ydown = -100000
	stop = 0
	for i in range(n):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		if not f1:
			if xl <= x and x <= xr:
				xl = x
			elif x < xl and (not f3):
				stop = 1
			elif x > xr:
				stop = 1
		if not f3:
			if xl <= x and x <= xr:
				xr = x
			elif x > xr and (not f1):
				stop = 1
			elif x < xl:
				stop = 1
		if not f2:
			if ydown <= y and y <= yup:
				yup = y
			elif y > yup and (not f4):
				stop = 1
			elif y < ydown:
				stop = 1
		if not f4:
			if ydown <= y and y <= yup:
				ydown = y
			elif y < ydown and (not f2):
				stop = 1
			elif y > yup:
				stop = 1
	if not stop:
		print(1, xr, yup)
	else:
		print(0)


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])


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	(l, r, u, d) = (-10 ** 5, 10 ** 5, 10 ** 5, -10 ** 5)
	for i in range(n):
		(x, y, a, b, c, D) = map(int, input().split())
		if a == 0:
			l = max(l, x)
		if b == 0:
			u = min(u, y)
		if c == 0:
			r = min(r, x)
		if D == 0:
			d = max(d, y)
	if l > r or d > u:
		print(0)
	else:
		print(1, l, u)


from math import *
from collections import *
import sys
sys.setrecursionlimit(10 ** 9)
t = int(input())
for y in range(t):
	n = int(input())
	l = d = -10 ** 5
	r = u = -l
	for i in range(n):
		a = list(map(int, input().split()))
		if a[2] == 0:
			l = max(l, a[0])
		if a[3] == 0:
			u = min(u, a[1])
		if a[5] == 0:
			d = max(d, a[1])
		if a[4] == 0:
			r = min(r, a[0])
	if l <= r and d <= u:
		print(1, r, u)
	else:
		print(0)


n = int(input())
for i in range(n):
	a = []
	t = int(input())
	for j in range(t):
		b = list(map(int, input().split()))
		a.append(b)
	m = 0
	q = 0
	p = 10 ** 5
	r = -10 ** 5
	Q = 0
	P = 10 ** 5
	R = -10 ** 5
	M = 0
	for j in a:
		x = j[0]
		y = j[1]
		if j[2] == 0 and j[4] == 0:
			if j[0] <= p and j[0] >= r:
				p = j[0]
				r = j[0]
				m = 1
			else:
				q = 1
				break
		elif j[2] == 1 and j[4] == 0:
			if m == 0:
				p = min(p, j[0])
			elif j[0] < p:
				q = 1
				break
		elif j[2] == 0 and j[4] == 1:
			if m == 0:
				r = max(r, j[0])
			elif j[0] > r:
				q = 1
				break
		else:
			pass
		if q == 1:
			break
		elif r > p:
			q = 1
			break
		if j[3] == 0 and j[5] == 0:
			if j[1] <= P and j[1] >= R:
				P = j[1]
				R = j[1]
				M = 1
			else:
				Q = 1
				break
		elif j[5] == 1 and j[3] == 0:
			if M == 0:
				P = min(P, j[1])
			elif j[1] < P:
				Q = 1
				break
		elif j[5] == 0 and j[3] == 1:
			if M == 0:
				R = max(R, j[1])
			elif j[1] > R:
				Q = 1
				break
		if Q == 1:
			break
		elif R > P:
			Q = 1
			break
	if q == 1 or Q == 1:
		print(0)
	else:
		print(1, p, P)


t = int(input())
for _ in range(t):
	n = int(input())
	xgt = []
	ygt = []
	xlt = []
	ylt = []
	xmax = 10 ** 5 + 1
	xmin = 10 ** 5 + 1
	ymax = 10 ** 5 + 1
	ymin = 10 ** 5 + 1
	flag = True
	for i in range(n):
		a = list(map(int, list(input().split())))
		if not a[2]:
			xgt.append(a[0])
		if not a[3]:
			ylt.append(a[1])
		if not a[4]:
			xlt.append(a[0])
		if not a[5]:
			ygt.append(a[1])
	if len(xgt):
		xmin = max(xgt)
	if len(xlt):
		xmax = min(xlt)
	if len(ylt):
		ymax = min(ylt)
	if len(ygt):
		ymin = max(ygt)
	if xmax > 10 ** 5:
		xmax = 10 ** 5
	if ymax > 10 ** 5:
		ymax = 10 ** 5
	if xmin > 10 ** 5:
		xmin = -10 ** 5
	if ymin > 10 ** 5:
		ymin = -10 ** 5
	if xmax < xmin:
		print('0')
		flag = False
	else:
		x = xmax
	if ymax < ymin:
		if flag:
			print('0')
		flag = False
	else:
		y = ymax
	if flag:
		print(1, x, y)


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])


for _ in range(int(input())):
	n = int(input())
	mxx = 100000
	mnx = -100000
	mxy = 100000
	mny = -100000
	for i in range(n):
		(x, y, left, up, right, down) = map(int, input().split())
		if left == 0:
			mnx = max(mnx, x)
		if right == 0:
			mxx = min(mxx, x)
		if up == 0:
			mxy = min(mxy, y)
		if down == 0:
			mny = max(mny, y)
	if mnx > mxx or mny > mxy:
		print(0)
	else:
		print(1, mxx, mxy)


import math

def intersection(rect1, rect2):
	left = max(rect1[0], rect2[0])
	up = min(rect1[1], rect2[1])
	right = min(rect1[2], rect2[2])
	down = max(rect1[3], rect2[3])
	return (left, up, right, down)
q = int(input())
for query in range(q):
	n = int(input())
	robots = [0] * n
	for line in range(n):
		array = input()
		robots[line] = tuple([int(x) for x in array.split()])
	rectangles = [0] * n
	for i in range(n):
		robot = robots[i]
		(left, up, right, down) = (None, None, None, None)
		if robot[2] == 1:
			left = -math.inf
		else:
			left = robot[0]
		if robot[3] == 1:
			up = math.inf
		else:
			up = robot[1]
		if robot[4] == 1:
			right = math.inf
		else:
			right = robot[0]
		if robot[5] == 1:
			down = -math.inf
		else:
			down = robot[1]
		rectangles[i] = (left, up, right, down)
	rect = rectangles[0]
	xr = [robot[0] for robot in robots]
	yr = [robot[1] for robot in robots]
	minix = min(xr)
	maxix = max(xr)
	miniy = min(yr)
	maxiy = max(yr)
	for rect1 in rectangles:
		rect = intersection(rect, rect1)
	left = rect[0]
	up = rect[1]
	right = rect[2]
	down = rect[3]
	if left <= right and down <= up:
		solution = [left, up]
		if left == -math.inf:
			solution[0] = minix
		if up == math.inf:
			solution[1] = maxiy
		print('1 ' + str(solution[0]) + ' ' + str(solution[1]))
	else:
		print(0)


t = int(input())
for i in range(t):
	n = int(input())
	maxy = maxx = 10 ** 5
	miny = minx = -maxx
	for i in range(n):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		if not f1:
			minx = max(minx, x)
		if not f4:
			miny = max(miny, y)
		if not f2:
			maxy = min(maxy, y)
		if not f3:
			maxx = min(x, maxx)
	if maxx >= minx and maxy >= miny:
		print(1, maxx, maxy)
	else:
		print(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)


for x in range(int(input())):
	n = int(input())
	xa = -10 ** 5
	xb = 10 ** 5
	ya = -10 ** 5
	yb = 10 ** 5
	for i in range(n):
		(a, b, x1, y2, x2, y1) = list(map(int, input().split()))
		if x1 == 0:
			xa = max(a, xa)
		if x2 == 0:
			xb = min(a, xb)
		if y1 == 0:
			ya = max(b, ya)
		if y2 == 0:
			yb = min(b, yb)
	if xb >= xa and yb >= ya:
		print(1, (xb + xa) // 2, (yb + ya) // 2)
	else:
		print(0)


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)


x = int(input())
for i in range(x):
	xmax = 100000
	xmin = -100000
	ymax = 100000
	ymin = -100000
	y = int(input())
	for j in range(y):
		r = input()
		lr = r.split(' ')
		for k in range(len(lr)):
			lr[k] = int(lr[k])
		if lr[2] == 0:
			xmin = max(xmin, lr[0])
		if lr[4] == 0:
			xmax = min(xmax, lr[0])
		if lr[5] == 0:
			ymin = max(ymin, lr[1])
		if lr[3] == 0:
			ymax = min(ymax, lr[1])
	if ymin > ymax or xmin > xmax:
		print(0)
	else:
		print(1)
		print(xmax)
		print(ymax)


queries = int(input())
for q in range(queries):
	num_rob = int(input())
	x_max = y_max = 100000
	x_min = y_min = -100000
	x_fin = set()
	y_fin = set()
	ret = 1
	for r in range(num_rob):
		line = list(map(int, input().split()))
		if not ret:
			continue
		(r_x, r_y) = line[:2]
		(lf, up, rt, dn) = line[2:]
		if not lf and (not rt):
			x_fin.add(r_x)
			if len(x_fin) > 1:
				ret = 0
				continue
		elif not lf and rt:
			x_min = max(x_min, r_x)
		elif lf and (not rt):
			x_max = min(x_max, r_x)
		if not dn and (not up):
			y_fin.add(r_y)
			if len(y_fin) > 1:
				ret = 0
				continue
		elif not dn and up:
			y_min = max(y_min, r_y)
		elif dn and (not up):
			y_max = min(y_max, r_y)
		if x_max < x_min:
			ret = 0
			continue
		if y_max < y_min:
			ret = 0
			continue
		for f in x_fin:
			if f > x_max or f < x_min:
				ret = 0
		for f in y_fin:
			if f > y_max or f < y_min:
				ret = 0
	(res_x, res_y) = (0, 0)
	if x_fin:
		res_x = x_fin.pop()
	else:
		res_x = x_min
	if y_fin:
		res_y = y_fin.pop()
	else:
		res_y = y_min
	print(ret, str(res_x) + ' ' + str(res_y) if ret else '')


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)


for _ in range(int(input())):
	n = int(input())
	(x, y, negx, posy, posx, negy) = ([], [], [], [], [], [])
	for i in range(n):
		(a, b, c, d, e, f) = map(int, input().split())
		x.append(a)
		y.append(b)
		negx.append(c)
		posy.append(d)
		posx.append(e)
		negy.append(f)
	(max_x, min_x, max_y, min_y) = (x[0], x[0], y[0], y[0])
	(f1, f2) = (1, 1)
	a = [x[i] for i in range(n) if posx[i] == 0]
	if a:
		max_x = min(a)
	else:
		f1 = 0
		max_x = max(x)
	a = [x[i] for i in range(n) if negx[i] == 0]
	if a:
		min_x = max(a)
	elif f1:
		min_x = min(x)
	else:
		min_x = max(x)
	a = [y[i] for i in range(n) if posy[i] == 0]
	if a:
		max_y = min(a)
	else:
		f2 = 0
		max_y = max(y)
	a = [y[i] for i in range(n) if negy[i] == 0]
	if a:
		min_y = max(a)
	elif f2:
		min_y = min(y)
	else:
		min_y = max(y)
	if max_x < min_x or max_y < min_y:
		print(0)
	else:
		print(1, max_x, min_y)


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)


I = input
for _ in [0] * int(I()):
	r = [10 ** 5] * 4
	for _ in [0] * int(I()):
		(x, y, *f) = map(int, I().split())
		r = [min(u, (v, u)[w]) for (u, v, w) in zip(r, (-x, y, x, -y), f)]
	(a, b, c, d) = r
	print(*([1, c, b], [0])[-a > c or -d > b])


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)


q = int(input())
inf = 10 ** 5
for _ in range(q):
	n = int(input())
	(lx, dy) = (-inf, -inf)
	(rx, uy) = (inf, inf)
	for k in range(n):
		t = input().split()
		(x, y) = map(int, t[:2])
		f = list(map(int, t[2:]))
		if f[0] == 0:
			lx = max(lx, x)
		if f[1] == 0:
			uy = min(uy, y)
		if f[2] == 0:
			rx = min(rx, x)
		if f[3] == 0:
			dy = max(dy, y)
	if lx > rx or dy > uy:
		print(0)
	else:
		(x, y) = ((lx + rx) // 2, (dy + uy) // 2)
		print(1, x, y)


for i in range(int(input())):
	num_ = int(input())
	(Left, Right, Down, Up) = (-10 ** 5, 10 ** 5, -10 ** 5, 10 ** 5)
	for j in range(num_):
		(x, y, d1, d2, d3, d4) = map(int, input().split())
		if d1 == 0:
			Left = max(x, Left)
		if d2 == 0:
			Up = min(y, Up)
		if d3 == 0:
			Right = min(x, Right)
		if d4 == 0:
			Down = max(y, Down)
	if Left > Right or Down > Up:
		print(0)
	else:
		print(1, Right, Up)


T = int(input())
for t in range(T):
	N = int(input())
	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(x, x1)
		if a == 0:
			y2 = min(y, y2)
		if d == 0:
			x2 = min(x, x2)
		if b == 0:
			y1 = max(y, y1)
	if x1 > x2 or y1 > y2:
		print(0)
	else:
		q = (x2 + x1) // 2
		r = (y2 + y1) // 2
		print(1, q, r)


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())
	x_pos = 10 ** 5
	y_pos = 10 ** 5
	y_neg = -10 ** 5
	x_neg = -10 ** 5
	for i in range(n):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		if f1 == 0:
			x_neg = max(x_neg, x)
		if f3 == 0:
			x_pos = min(x_pos, x)
		if f2 == 0:
			y_pos = min(y_pos, y)
		if f4 == 0:
			y_neg = max(y_neg, y)
	if y_neg > y_pos or x_neg > x_pos:
		print(0)
	else:
		print(1, x_neg, y_pos)


import sys
import math
q = int(sys.stdin.readline())
for _ in range(q):
	n = int(sys.stdin.readline())
	minx = -10 ** 5
	maxx = 10 ** 5
	maxy = 10 ** 5
	miny = -10 ** 5
	for _ in range(n):
		(x, y, f1, f2, f3, f4) = map(int, sys.stdin.readline().split())
		if f1 == 1 and f2 == 1 and (f3 == 1) and (f4 == 1):
			continue
		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, maxx, miny)


import sys
n = int(input())
I = lambda : map(int, sys.stdin.readline().split())
for _ in range(n):
	x = int(input())
	t = 0
	xmax = 10 ** 5
	xmin = -10 ** 5
	ymax = 10 ** 5
	ymin = -10 ** 5
	ans = 0
	for i in range(x):
		(x1, y1, a1, a2, a3, a4) = I()
		if a1 == 0:
			if xmax < x1:
				ans = -1
			else:
				xmin = max(xmin, x1)
		if a2 == 0:
			if ymin > y1:
				ans = -1
			else:
				ymax = min(ymax, y1)
		if a3 == 0:
			if x1 < xmin:
				ans = -1
			else:
				xmax = min(xmax, x1)
		if a4 == 0:
			if y1 > ymax:
				ans = -1
			else:
				ymin = max(ymin, y1)
	if ans == -1:
		print('0')
	else:
		t1 = (xmin + xmax) / 2
		t2 = (ymin + ymax) / 2
		print('1', int(t1), int(t2))


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)


q = int(input())
while q > 0:
	q -= 1
	n = int(input())
	robots = []
	for i in range(n):
		robot = list(map(int, input().split()))
		robots.append(robot)
	inf = float('inf')
	xmax = inf
	xmin = -inf
	ymax = inf
	ymin = -inf
	possible = True
	for robot in robots:
		(x, y) = robot[0:2]
		dirs = robot[2:]
		_xmin = -inf
		_xmax = inf
		_ymin = -inf
		_ymax = inf
		if dirs[0] == 0:
			_xmin = x
		if dirs[1] == 0:
			_ymax = y
		if dirs[2] == 0:
			_xmax = x
		if dirs[3] == 0:
			_ymin = y
		xmax = min(xmax, _xmax)
		ymax = min(ymax, _ymax)
		xmin = max(xmin, _xmin)
		ymin = max(ymin, _ymin)
		if not (xmin <= xmax and ymin <= ymax):
			possible = False
	if possible:
		print(1, min(xmax, int(100000.0)), min(ymax, int(100000.0)))
	else:
		print(0)


t = int(input())
INF = 10 ** 5
for _ in range(t):
	n = int(input())
	up = INF
	rt = INF
	lt = -INF
	dn = -INF
	for i in range(n):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		if not f1:
			lt = max(lt, x)
		if not f2:
			up = min(up, y)
		if not f3:
			rt = min(rt, x)
		if not f4:
			dn = max(dn, y)
	if lt <= rt and up >= dn:
		print(1, rt, up)
	else:
		print(0)


mod = 10 ** 9 + 7
t = int(input())
for _ in range(t):
	n = int(input())
	u = r = 10 ** 5
	l = d = -1 * 10 ** 5
	for i in range(n):
		a = [int(i) for i in input().split()]
		if a[2] == 0:
			l = max(l, a[0])
		if a[3] == 0:
			u = min(u, a[1])
		if a[4] == 0:
			r = min(r, a[0])
		if a[5] == 0:
			d = max(d, a[1])
	if l <= r and u >= d:
		print(1, r, u)
	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]))


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
(t,) = I()
m = [[-1, 0], [0, 1], [1, 0], [0, -1]]
while t:
	t -= 1
	(n,) = I()
	d1 = [10 ** 5, -10 ** 5]
	d2 = [10 ** 5, -10 ** 5]
	for i in range(n):
		(x, y, a1, a2, a3, a4) = I()
		if a1 == 0:
			d1[1] = max(d1[1], x)
		if a2 == 0:
			d2[0] = min(d2[0], y)
		if a3 == 0:
			d1[0] = min(d1[0], x)
		if a4 == 0:
			d2[1] = max(d2[1], y)
	if d1[1] > d1[0]:
		print(0)
		continue
	elif d2[1] > d2[0]:
		print(0)
		continue
	else:
		print(1, d1[0], d2[0])


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))


import sys
input = sys.stdin.readline
RI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
rw = lambda : input().strip().split()
infinite = float('inf')
t = int(input())
for _ in range(t):
	n = int(input())
	l = [[] for i in range(n)]
	for i in range(n):
		l[i] = RI()
	startx = -100000
	starty = -100000
	endx = 100000
	endy = 100000
	xf = 1000000
	yf = 1000000
	while startx <= endx:
		mid = (startx + endx) // 2
		flag = 0
		for i in range(n):
			if l[i][0] == mid:
				continue
			elif l[i][0] < mid and l[i][4] == 1:
				continue
			elif l[i][0] < mid and l[i][4] == 0:
				endx = l[i][0]
				flag = 1
				break
			elif l[i][0] > mid and l[i][2] == 1:
				continue
			else:
				startx = l[i][0]
				flag = 1
				break
		if flag == 0:
			xf = mid
			break
	while starty <= endy:
		mid = (starty + endy) // 2
		flag = 0
		for i in range(n):
			if l[i][1] == mid:
				continue
			elif l[i][1] < mid and l[i][3] == 1:
				continue
			elif l[i][1] < mid and l[i][3] == 0:
				endy = l[i][1]
				flag = 1
				break
			elif l[i][1] > mid and l[i][5] == 1:
				continue
			else:
				starty = l[i][1]
				flag = 1
				break
		if flag == 0:
			yf = mid
			break
	if xf == 1000000 or yf == 1000000:
		print(0)
	else:
		print(1, end=' ')
		print(xf, end=' ')
		print(yf)


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])


q = int(input())
for _ in range(q):
	n = int(input())
	l = d = -1 * 10 ** 5
	u = r = 10 ** 5
	for _ in range(n):
		s = [int(x) for x in input().split()]
		if s[2] == 0:
			l = max(l, s[0])
		if s[3] == 0:
			u = min(u, s[1])
		if s[4] == 0:
			r = min(r, s[0])
		if s[5] == 0:
			d = max(d, s[1])
	if l <= r and d <= u:
		lt = [1] + [(l + r) // 2] + [(u + d) // 2]
		print(*lt)
	else:
		print(0)


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()


from sys import stdin, stdout
import cProfile, math
from collections import Counter, defaultdict, deque
from bisect import bisect_left, bisect, bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
import operator as op
from functools import reduce
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)
fac_warmup = False
printHeap = str()
memory_constrained = False
P = 10 ** 9 + 7
import sys

class merge_find:

	def __init__(self, n):
		self.parent = list(range(n))
		self.size = [1] * n
		self.num_sets = n
		self.lista = [[_] for _ in range(n)]

	def find(self, a):
		to_update = []
		while a != self.parent[a]:
			to_update.append(a)
			a = self.parent[a]
		for b in to_update:
			self.parent[b] = a
		return self.parent[a]

	def merge(self, a, b):
		a = self.find(a)
		b = self.find(b)
		if a == b:
			return
		if self.size[a] < self.size[b]:
			(a, b) = (b, a)
		self.num_sets -= 1
		self.parent[b] = a
		self.size[a] += self.size[b]
		self.lista[a] += self.lista[b]

	def set_size(self, a):
		return self.size[self.find(a)]

	def __len__(self):
		return self.num_sets

def display(string_to_print):
	stdout.write(str(string_to_print) + '\n')

def primeFactors(n):
	factors = dict()
	for i in range(2, math.ceil(math.sqrt(n)) + 1):
		while n % i == 0:
			if i in factors:
				factors[i] += 1
			else:
				factors[i] = 1
			n = n // i
	if n > 2:
		factors[n] = 1
	return factors

def all_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 fibonacci_modP(n, MOD):
	if n < 2:
		return 1
	return (cached_fn(fibonacci_modP, (n + 1) // 2, MOD) * cached_fn(fibonacci_modP, n // 2, MOD) + cached_fn(fibonacci_modP, (n - 1) // 2, MOD) * cached_fn(fibonacci_modP, (n - 2) // 2, MOD)) % MOD

def factorial_modP_Wilson(n, p):
	if p <= n:
		return 0
	res = p - 1
	for i in range(n + 1, p):
		res = res * cached_fn(InverseEuler, i, p) % p
	return res

def binary(n, digits=20):
	b = bin(n)[2:]
	b = '0' * (digits - len(b)) + b
	return b

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

def generate_primes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	return prime
factorial_modP = []

def warm_up_fac(MOD):
	nonlocal factorial_modP, fac_warmup
	if fac_warmup:
		return
	factorial_modP = [1 for _ in range(fac_warmup_size + 1)]
	for i in range(2, fac_warmup_size):
		factorial_modP[i] = factorial_modP[i - 1] * i % MOD
	fac_warmup = True

def InverseEuler(n, MOD):
	return pow(n, MOD - 2, MOD)

def nCr(n, r, MOD):
	nonlocal fac_warmup, factorial_modP
	if not fac_warmup:
		warm_up_fac(MOD)
		fac_warmup = True
	return factorial_modP[n] * (pow(factorial_modP[r], MOD - 2, MOD) * pow(factorial_modP[n - r], MOD - 2, MOD) % MOD) % MOD

def test_print(*args):
	if testingMode:
		print(args)

def display_list(list1, sep=' '):
	stdout.write(sep.join(map(str, list1)) + '\n')

def display_2D_list(li):
	for i in li:
		print(i)

def prefix_sum(li):
	sm = 0
	res = []
	for i in li:
		sm += i
		res.append(sm)
	return res

def get_int():
	return int(stdin.readline().strip())

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

def get_list():
	return list(map(int, stdin.readline().split()))
import heapq, itertools
pq = []
entry_finder = {}
REMOVED = '<removed-task>'

def add_task(task, priority=0):
	if task in entry_finder:
		remove_task(task)
	count = next(counter)
	entry = [priority, count, task]
	entry_finder[task] = entry
	heapq.heappush(pq, entry)

def remove_task(task):
	entry = entry_finder.pop(task)
	entry[-1] = REMOVED

def pop_task():
	while pq:
		(priority, count, task) = heapq.heappop(pq)
		if task is not REMOVED:
			del entry_finder[task]
			return task
	raise KeyError('pop from an empty priority queue')
memory = dict()

def clear_cache():
	nonlocal memory
	memory = dict()

def cached_fn(fn, *args):
	nonlocal memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result

def ncr(n, r):
	return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))

def binary_serach(i, li):
	fn = lambda x: li[x] - x // i
	x = -1
	b = len(li)
	while b >= 1:
		while b + x < len(li) and fn(b + x) > 0:
			x += b
		b = b // 2
	return x
TestCases = True
testingMode = False
fac_warmup_size = 10 ** 5 + 100
optimiseForReccursion = False
from math import factorial

def main():
	n = get_int()
	minx = -10 ** 5
	maxx = 10 ** 5
	miny = -10 ** 5
	maxy = 10 ** 5
	for _ in range(n):
		(xi, yi, nx, py, px, ny) = get_tuple()
		if nx == 0:
			minx = max(minx, xi)
		if ny == 0:
			miny = max(miny, yi)
		if px == 0:
			maxx = min(maxx, xi)
		if py == 0:
			maxy = min(maxy, yi)
	if maxx - minx >= 0 and maxy - miny >= 0:
		print(1, minx, miny)
	else:
		print(0)
if TestCases:
	for i in range(get_int()):
		cProfile.run('main()') if testingMode else main()
else:
	(cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()


q = int(input())
for _ in range(q):
	n = int(input())
	x_right = 100000
	y_down = -100000
	x_left = -100000
	y_up = 100000
	for i in range(n):
		arr = list(map(int, input().split()))
		if arr[2] == 0 and x_left < arr[0]:
			x_left = arr[0]
		if arr[3] == 0 and y_up > arr[1]:
			y_up = arr[1]
		if arr[4] == 0 and x_right > arr[0]:
			x_right = arr[0]
		if arr[5] == 0 and y_down < arr[1]:
			y_down = arr[1]
	if x_right < x_left or y_up < y_down:
		print(0)
	else:
		print(1, x_right, y_up)


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 print_function
from collections import Counter, OrderedDict
from itertools import permutations as perm
from fractions import Fraction
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')
(t,) = gil()
for _ in range(t):
	(xmin, xmax) = (-int(100000.0), int(100000.0))
	(ymin, ymax) = (xmin, xmax)
	(n,) = gil()
	isPos = True
	for _ in range(n):
		(rx, ry, lt, up, rt, dw) = gil()
		if not isPos:
			continue
		if lt ^ rt:
			if lt:
				isPos &= xmin <= rx
				xmax = min(xmax, rx)
			else:
				isPos &= rx <= xmax
				xmin = max(xmin, rx)
		elif lt == rt == 0:
			isPos &= xmin <= rx <= xmax
			xmax = xmin = rx
		if up ^ dw:
			if up:
				isPos &= ry <= ymax
				ymin = max(ymin, ry)
			else:
				isPos &= ry >= ymin
				ymax = min(ymax, ry)
		elif up == dw == 0:
			isPos &= ymin <= ry <= ymax
			ymax = ymin = ry
	if isPos:
		print(1, xmin, ymin)
	else:
		print(0)


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())
inf = 10 ** 5
for _ in range(q):
	n = int(input())
	l = -inf
	r = +inf
	u = +inf
	d = -inf
	for xi in range(n):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		if not f1:
			l = max(x, l)
		if not f2:
			u = min(y, u)
		if not f3:
			r = min(x, r)
		if not f4:
			d = max(y, d)
	if l > r or d > u:
		print(0)
	else:
		print(1, (l + r) // 2, (u + d) // 2)


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()


q = int(input())
for i in range(q):
	n = int(input())
	top = 100000
	bottom = -100000
	left = -100000
	right = 100000
	for i in range(n):
		ints = [int(x) for x in input().split()]
		if ints[2] == 0:
			left = max(ints[0], left)
		if ints[3] == 0:
			top = min(ints[1], top)
		if ints[4] == 0:
			right = min(ints[0], right)
		if ints[5] == 0:
			bottom = max(ints[1], bottom)
	if left > right or bottom > top:
		print('0')
	else:
		print('1 ' + str(left) + ' ' + str(top))


import random
q = int(input())
inf = 100000
for i in range(q):
	n = int(input())
	miy = -inf
	may = inf
	miX = -inf
	maX = inf
	for i in range(n):
		(x, y, left, up, right, down) = [int(i) for i in input().split()]
		if not down:
			miy = max(y, miy)
		if not up:
			may = min(y, may)
		if not left:
			miX = max(miX, x)
		if not right:
			maX = min(x, maX)
	if maX < miX or may < miy:
		print(0)
	else:
		print(1, random.randint(miX, maX), random.randint(miy, may))


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


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 q in range(int(input())):
	n = int(input())
	Range = ['n', 'n', 'n', 'n']
	for curr_rob in range(n):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		xy = [x, y]
		for (i, k) in enumerate([f1, f3, f4, f2]):
			if k == 0:
				t = xy[i // 2]
				if Range[i] == 'n':
					Range[i] = t
				elif i % 2 == 0:
					if Range[i] < t:
						Range[i] = t
				elif Range[i] > t:
					Range[i] = t
	if True:
		imp = False
		if not (Range[0] == 'n' or Range[1] == 'n'):
			if Range[0] > Range[1]:
				imp = True
		if not (Range[2] == 'n' or Range[3] == 'n'):
			if Range[2] > Range[3]:
				imp = True
		if not imp:
			if Range[0] == 'n':
				if Range[1] == 'n':
					Range[0] = 1
				else:
					Range[0] = Range[1]
			if Range[2] == 'n':
				if Range[3] == 'n':
					Range[2] = 1
				else:
					Range[2] = Range[3]
			print(1, Range[0], Range[2])
		else:
			print(0)


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')


import math
t = int(input())
for _ in range(t):
	n = int(input())
	x1 = -1000000000.0
	x2 = 1000000000.0
	x3 = 1
	x4 = -1000000000.0
	x5 = 1000000000.0
	x6 = 1
	for i in range(n):
		l = [int(x) for x in input().split()]
		(l[3], l[4]) = (l[4], l[3])
		if l[2] == 0 and l[3] == 0:
			if l[0] >= x1 and l[0] <= x2:
				x1 = l[0]
				x2 = l[0]
			else:
				x3 = 0
		elif l[2] == 0 and l[3] == 1:
			if l[0] > x2:
				x3 = 0
			elif l[0] >= x1:
				x1 = l[0]
		elif l[2] == 1 and l[3] == 0:
			if l[0] < x1:
				x3 = 0
			elif l[0] <= x2:
				x2 = l[0]
		if l[4] == 0 and l[5] == 0:
			if l[1] >= x4 and l[1] <= x5:
				x4 = l[1]
				x5 = l[1]
			else:
				x6 = 0
		elif l[4] == 0 and l[5] == 1:
			if l[1] < x4:
				x6 = 0
			elif l[1] <= x5:
				x5 = l[1]
		elif l[4] == 1 and l[5] == 0:
			if l[1] > x5:
				x6 = 0
			elif l[1] >= x4:
				x4 = l[1]
	if x3 == 0 or x6 == 0:
		print(0)
	else:
		X = 0
		Y = 0
		if x1 == -1000000000.0:
			if x2 == 1000000000.0:
				X = 0
			else:
				X = x2
		else:
			X = x1
		if x4 == -1000000000.0:
			if x5 == 1000000000.0:
				Y = 0
			else:
				Y = x5
		else:
			Y = x4
		print(1, X, Y)


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])


q = int(input())
f = []
for i in range(q):
	n = int(input())
	b1 = -10 ** 5
	b2 = 10 ** 5
	b3 = 10 ** 5
	b4 = -10 ** 5
	for j in range(n):
		(xi, yi, f1, f2, f3, f4) = map(int, input().split())
		if f1 == 0 and xi > b1:
			b1 = xi
		if f2 == 0 and yi < b2:
			b2 = yi
		if f3 == 0 and xi < b3:
			b3 = xi
		if f4 == 0 and yi > b4:
			b4 = yi
	if b1 <= b3 and b2 >= b4:
		f += [[1, b1, b2]]
	else:
		f += [[0]]
for i in range(q):
	print(' '.join(map(str, f[i])))


numOfQueries = int(input())
targets = []
for i in range(0, numOfQueries):
	numOfRobotsInQuery = int(input())
	robots = []
	for j in range(0, numOfRobotsInQuery):
		(xi, yi, fi1, fi2, fi3, fi4) = list(map(int, input().split()))
		robots.append([xi, yi, fi1, fi2, fi3, fi4])
	robotsCantMoveLeft = [_[0] for _ in robots if _[2] == 0]
	leftBound = -100000
	if len(robotsCantMoveLeft) > 0:
		leftBound = max(robotsCantMoveLeft)
	rightBound = 100000
	robotsCantMoveRight = [_[0] for _ in robots if _[4] == 0]
	if len(robotsCantMoveRight) > 0:
		rightBound = min(robotsCantMoveRight)
	upperBound = 100000
	robotsCantMoveUp = [_[1] for _ in robots if _[3] == 0]
	if len(robotsCantMoveUp) > 0:
		upperBound = min(robotsCantMoveUp)
	lowerBound = -100000
	robotsCantMoveDown = [_[1] for _ in robots if _[5] == 0]
	if len(robotsCantMoveDown) > 0:
		lowerBound = max(robotsCantMoveDown)
	if leftBound > rightBound or lowerBound > upperBound:
		targets.append([0, 0, 0])
	else:
		targets.append([1, leftBound, lowerBound])
for i in targets:
	if i[0] == 0:
		print(0)
	else:
		print(1, ' ', i[1], ' ', i[2])
exit(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)


T = int(input())
for t in range(T):
	R = int(input())
	x1 = -10 ** 5
	x2 = 10 ** 5
	y1 = -10 ** 5
	y2 = 10 ** 5
	for n in range(R):
		L = list(map(int, input().split()))
		if L[2] == 0:
			x1 = max(x1, L[0])
		if L[4] == 0:
			x2 = min(x2, L[0])
		if L[3] == 0:
			y2 = min(y2, L[1])
		if L[5] == 0:
			y1 = max(y1, L[1])
	if x1 > x2 or y1 > y2:
		print(0)
	else:
		x = (x2 + x1) // 2
		y = (y2 + y1) // 2
		print(1, x, y)


from sys import stdin
q = int(stdin.readline())
for i in range(q):
	n = int(stdin.readline())
	ans = []
	for i in range(n):
		(l, u, r, d) = (-100000, 100000, 100000, -100000)
		(x, y, f1, f2, f3, f4) = map(int, stdin.readline().split())
		if f1 == 0:
			l = max(x, l)
		if f2 == 0:
			u = min(y, u)
		if f3 == 0:
			r = min(x, r)
		if f4 == 0:
			d = max(y, d)
		ans.append([l, r, u, d])
	(a, b, c, d) = (ans[0][0], ans[0][1], ans[0][2], ans[0][3])
	for i in range(1, len(ans)):
		a = max(ans[i][0], a)
		b = min(ans[i][1], b)
		c = min(ans[i][2], c)
		d = max(ans[i][3], d)
	cond = True
	if a > b or d > c:
		cond = False
	else:
		pass
	if cond == True:
		print(1, a, c)
	else:
		print(0)


for _ in range(int(input())):
	max_x = max_y = 100000
	min_x = min_y = -100000
	for _2 in range(int(input())):
		(xs, ys, f1, f2, f3, f4) = input().split()
		(x, y) = (int(xs), int(ys))
		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 max_x < min_x or min_y > max_y:
		print('0')
	else:
		print(1, max_x, max_y)


q = int(input())
for _ in range(q):
	n = int(input())
	l = b = -10 ** 5
	t = r = 10 ** 5
	for _ in range(n):
		(x, y, cl, ct, cr, cb) = map(int, input().split())
		if not cl:
			l = max(x, l)
		if not cr:
			r = min(x, r)
		if not ct:
			t = min(y, t)
		if not cb:
			b = max(y, b)
	if l > r or t < b:
		print(0)
	else:
		print(1, l, t)


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)


for _ in range(int(input())):
	n = int(input())
	(x1, x2, x3, x4) = (-10 ** 5, 10 ** 5, 10 ** 5, -10 ** 5)
	for i in range(n):
		(pos_x, pos_y, f1, f2, f3, f4) = map(int, input().split())
		if not f1:
			x1 = max(x1, pos_x)
		if not f2:
			x2 = min(pos_y, x2)
		if not f3:
			x3 = min(pos_x, x3)
		if not f4:
			x4 = max(x4, pos_y)
	if x1 > x3 or x4 > x2:
		print(0)
	else:
		print(1, x1, x2)


T = int(input())
for _ in range(T):
	n = int(input())
	flag = 0
	kx1 = -100000
	kx2 = 100000
	ky1 = -100000
	ky2 = 100000
	for i in range(n):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		if f1 == 0:
			kx1 = max(kx1, x)
		if f2 == 0:
			ky2 = min(ky2, y)
		if f3 == 0:
			kx2 = min(kx2, x)
		if f4 == 0:
			ky1 = max(ky1, y)
	if kx1 > kx2 or ky2 < ky1:
		print(0)
	else:
		t1 = kx1
		t2 = ky2
		print(1, t1, t2)


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))))


from math import inf

def intersect_regions(first, second):
	(t0, l0, b0, r0) = first
	(t1, l1, b1, r1) = second
	x_overlap = t0 >= b1 if t0 < t1 else t1 >= b0
	y_overlap = r0 >= l1 if r0 < r1 else r1 >= l0
	if not (x_overlap and y_overlap):
		return None
	tlr = [min(t0, t1), max(l0, l1)]
	brr = [max(b0, b1), min(r0, r1)]
	return tlr + brr

def solve(robots):
	possible = [inf, -inf, -inf, inf]
	for (x, y, down, right, up, left) in robots:
		accessible = [x, y, x, y]
		if up:
			accessible[0] = inf
		if left:
			accessible[1] = -inf
		if down:
			accessible[2] = -inf
		if right:
			accessible[3] = inf
		intersection = intersect_regions(possible, accessible)
		if intersection is None:
			return (False, (0, 0))
		possible = intersection
	if possible[0] <= 0:
		result_x = possible[0]
	elif possible[2] > 0:
		result_x = possible[2]
	else:
		result_x = 0
	if possible[3] <= 0:
		result_y = possible[3]
	elif possible[1] > 0:
		result_y = possible[1]
	else:
		result_y = 0
	return (True, (result_x, result_y))
q = int(input().rstrip())
for _ in range(q):
	n = int(input().rstrip())
	robots = []
	for _ in range(n):
		robots.append(list(map(int, input().rstrip().split())))
	(exists, (x, y)) = solve(robots)
	if exists:
		print('1 {} {}'.format(x, y))
	else:
		print('0')


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)


import copy
import random
import sys
lines = []
for line in sys.stdin:
	lines.append(line)
n_queries = [int(x) for x in lines[0].split()]
n_queries = n_queries[0]
n = 0
for idxQuery in range(n_queries):
	line_num_robot = n + 1
	num_robot = [int(x) for x in lines[line_num_robot].split()]
	num_robot = num_robot[0]
	robot_pos = []
	robot_mov = []
	for idxRobot in range(num_robot):
		info = [int(x) for x in lines[idxRobot + 1 + line_num_robot].split()]
		robot_pos.append([copy.deepcopy(info[0]), copy.deepcopy(info[1])])
		robot_mov.append([copy.deepcopy(info[2]), copy.deepcopy(info[3]), copy.deepcopy(info[4]), copy.deepcopy(info[5])])
	target = [-100001, -100001]
	fail_x_minus = []
	fail_x_plus = []
	fail_y_minus = []
	fail_y_plus = []
	for idxRobot in range(len(robot_mov)):
		if robot_mov[idxRobot][0] == 0:
			fail_x_minus.append(copy.deepcopy(idxRobot))
		if robot_mov[idxRobot][1] == 0:
			fail_y_plus.append(copy.deepcopy(idxRobot))
		if robot_mov[idxRobot][2] == 0:
			fail_x_plus.append(copy.deepcopy(idxRobot))
		if robot_mov[idxRobot][3] == 0:
			fail_y_minus.append(copy.deepcopy(idxRobot))
	upper_x = 100001
	upper_y = 100001
	lower_x = -100001
	lower_y = -100001
	for (_, idxRobot) in enumerate(fail_x_plus):
		if robot_pos[idxRobot][0] < upper_x:
			upper_x = robot_pos[idxRobot][0]
	if upper_x == 100001:
		upper_x = 100000
	for (_, idxRobot) in enumerate(fail_x_minus):
		if robot_pos[idxRobot][0] > lower_x:
			lower_x = robot_pos[idxRobot][0]
	if lower_x == -100001:
		lower_x = -100000
	for (_, idxRobot) in enumerate(fail_y_plus):
		if robot_pos[idxRobot][1] < upper_y:
			upper_y = robot_pos[idxRobot][1]
	if upper_y == 100001:
		upper_y = 100000
	for (_, idxRobot) in enumerate(fail_y_minus):
		if robot_pos[idxRobot][1] > lower_y:
			lower_y = robot_pos[idxRobot][1]
	if lower_y == -100001:
		lower_y = -100000
	if lower_x <= upper_x and lower_y <= upper_y:
		print('1 ', random.randint(lower_x, upper_x), ' ', random.randint(lower_y, upper_y))
	else:
		print('0')
	n = line_num_robot + num_robot


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)


T = int(input())
t = 0
while t < T:
	N = int(input())
	n = 0
	x1 = -100000
	x2 = 100000
	y1 = -100000
	y2 = 100000
	while n < 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)
		n += 1
	if x1 <= x2 and y1 <= y2:
		print('1 ', x1, ' ', y1)
	else:
		print('0')
		n += 1
	t += 1


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))


(L, U, R, D) = (0, 1, 2, 3)

def isValid(bb):
	return (not bb[R] or not bb[L] or bb[L] <= bb[R]) and (not bb[U] or not bb[D] or bb[D] <= bb[U])
t = int(input())
for _ in range(t):
	noprint = False
	r = int(input())
	bb = [None] * 4
	for ri in range(r):
		(x, y, l, u, r, d) = map(int, input().split())
		if noprint:
			continue
		if not r:
			bb[R] = min(bb[R], x) if bb[R] is not None else x
		if not l:
			bb[L] = max(bb[L], x) if bb[L] is not None else x
		if not u:
			bb[U] = min(bb[U], y) if bb[U] is not None else y
		if not d:
			bb[D] = max(bb[D], y) if bb[D] is not None else y
		if not isValid(bb):
			print('0')
			noprint = True
	if not noprint:
		print('1', bb[L] if bb[L] is not None else bb[R] if bb[R] is not None else 0, bb[D] if bb[D] is not None else bb[U] if bb[U] is not None else 0)


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
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	upl = 100000
	lol = -100000
	lel = -100000
	ril = 100000
	n = int(input())
	for i in range(n):
		ab = list(map(int, input().split()))
		if ab[2] == 0 and ab[0] > lel:
			lel = ab[0]
		if ab[3] == 0 and ab[1] < upl:
			upl = ab[1]
		if ab[4] == 0 and ab[0] < ril:
			ril = ab[0]
		if ab[5] == 0 and ab[1] > lol:
			lol = ab[1]
	if upl < lol or ril < lel:
		print(0)
	else:
		print(1, int((ril + lel) // 2), int((upl + lol) // 2))


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')


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	c = []
	f = []
	for i in range(n):
		l = list(map(int, input().split()))
		c.append(l[:2])
		f.append(l[2:])
	l = -10 ** 5
	u = 10 ** 5
	r = 10 ** 5
	d = -10 ** 5
	for i in range(n):
		if f[i][0] == 0:
			l = max(l, c[i][0])
		if f[i][1] == 0:
			u = min(u, c[i][1])
		if f[i][2] == 0:
			r = min(r, c[i][0])
		if f[i][3] == 0:
			d = max(d, c[i][1])
	if l <= r and u >= d:
		print(1, l, u)
	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)


q = int(input())
for i in range(q):
	n = int(input())
	l = -10 ** 5
	u = 10 ** 5
	r = 10 ** 5
	d = -10 ** 5
	for j in range(n):
		w = input().split()
		if w[2] == '0' and l < int(w[0]):
			l = int(w[0])
		if w[3] == '0' and u > int(w[1]):
			u = int(w[1])
		if w[4] == '0' and r > int(w[0]):
			r = int(w[0])
		if w[5] == '0' and d < int(w[1]):
			d = int(w[1])
	if r < l or u < d:
		print(0)
	else:
		print(str(1) + ' ' + str(l) + ' ' + str(u))


from sys import stdin, stdout
input = stdin.readline
for _ in range(int(input())):
	x = 10 ** 5
	n = int(input())
	(l, u, r, d) = (-x, x, x, -x)
	for i in range(n):
		a = list(map(int, input().split()))
		if a[2] == 0:
			if l <= a[0]:
				l = a[0]
		if a[4] == 0:
			if r >= a[0]:
				r = a[0]
		if a[3] == 0:
			if u >= a[1]:
				u = a[1]
		if a[5] == 0:
			if d <= a[1]:
				d = a[1]
	if l <= r and u >= d:
		stdout.write('1' + ' ' + str(l) + ' ' + str(u) + '\n')
	else:
		stdout.write('0' + '\n')


q = int(input())
for i in range(q):
	n = int(input())
	lx = ['*', '*']
	ly = ['*', '*']
	for j in range(n):
		(x, y, left, up, right, down) = map(int, input().split())
		if left == 0:
			if lx[0] == '*':
				lx[0] = x
			else:
				lx[0] = max(lx[0], x)
		if right == 0:
			if lx[1] == '*':
				lx[1] = x
			else:
				lx[1] = min(lx[1], x)
		if down == 0:
			if ly[0] == '*':
				ly[0] = y
			else:
				ly[0] = max(ly[0], y)
		if up == 0:
			if ly[1] == '*':
				ly[1] = y
			else:
				ly[1] = min(ly[1], y)
	if lx[0] != '*' and lx[1] != '*':
		if lx[1] >= lx[0]:
			x1 = lx[0]
		else:
			print(0)
			continue
	elif lx[0] != '*':
		x1 = lx[0]
	elif lx[1] != '*':
		x1 = lx[1]
	else:
		x1 = 0
	if ly[0] != '*' and ly[1] != '*':
		if ly[1] >= ly[0]:
			y1 = ly[0]
		else:
			print(0)
			continue
	elif ly[0] != '*':
		y1 = ly[0]
	elif ly[1] != '*':
		y1 = ly[1]
	else:
		y1 = 0
	if -100000 <= x1 <= 100000 and -100000 <= y1 <= 100000:
		print('1 ' + str(x1) + ' ' + str(y1))
	else:
		print(0)


q = int(input())
min = -100000
max = 100000
for req in range(q):
	n = int(input())
	min_x = min
	max_x = max
	min_y = min
	max_y = max
	for i in range(n):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		if f1 == 0 and min_x < x:
			min_x = x
		if f2 == 0 and max_y > y:
			max_y = y
		if f3 == 0 and max_x > x:
			max_x = x
		if f4 == 0 and min_y < y:
			min_y = y
	if min_x > max_x or min_y > max_y:
		print(0)
	else:
		print(1, (min_x + max_x) // 2, (min_y + max_y) // 2)


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()


q = int(input())
ne = -100009
inf = 100009
for _ in range(q):
	n = int(input())
	subx = ne
	supx = inf
	suby = ne
	supy = inf
	for i in range(n):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		if f1 == 0:
			subx = max(subx, x)
		if f2 == 0:
			supy = min(supy, y)
		if f3 == 0:
			supx = min(supx, x)
		if f4 == 0:
			suby = max(suby, y)
	if supx >= subx and supy >= suby:
		if supx > 100000:
			supx = 100000
		if supy > 100000:
			supy = 100000
		print(1, supx, supy)
	else:
		print(0)


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()


import atexit, io, sys
input_lines = sys.stdin.read().splitlines()
input = iter(input_lines).__next__
out_buffer = io.StringIO()
sys.stdout = out_buffer

@atexit.register
def write():
	sys.__stdout__.write(out_buffer.getvalue())

def line():
	inp = input().split()
	if len(inp) == 1:
		return int(inp[0])
	return map(int, inp)
from itertools import repeat
from math import inf, isinf
q = line()
for _ in repeat(None, q):
	n = line()
	bots = [tuple(line()) for _ in repeat(None, n)]
	limits = [inf, inf, inf, inf]
	for bot in bots:
		xy = bot[:2]
		fs = bot[2:]
		for (i, f) in enumerate(fs):
			w = xy[i % 2] * (1 if i in [1, 2] else -1)
			if not f and w < limits[i]:
				limits[i] = w
		if limits[2] < -limits[0] or limits[1] < -limits[3]:
			print('0')
			break
	else:
		if isinf(limits[2]):
			if isinf(limits[0]):
				limits[2] = 0
			else:
				limits[2] = -limits[0]
		if isinf(limits[1]):
			if isinf(limits[3]):
				limits[1] = 0
			else:
				limits[1] = -limits[3]
		print('1 {} {}'.format(limits[2], limits[1]))


for _ in range(int(input())):
	n = int(input())
	l = d = -10 ** 5
	r = u = 10 ** 5
	for i in range(n):
		a = list(map(int, input().split()))
		if a[2] == 0:
			l = max(l, a[0])
		if a[3] == 0:
			u = min(u, a[1])
		if a[4] == 0:
			r = min(r, a[0])
		if a[5] == 0:
			d = max(d, a[1])
	if l <= r and d <= u:
		print(1, r, u)
	else:
		print(0)


for t in range(int(input())):
	n = int(input())
	(top, bottom, left, right) = (100000.0, -100000.0, -100000.0, 100000.0)
	for i in range(n):
		(x, y, f1, f2, f3, f4) = [int(x) for x in input().split()]
		if f1 == 0:
			bottom = max(bottom, x)
		if f3 == 0:
			top = min(top, x)
		if f2 == 0:
			right = min(right, y)
		if f4 == 0:
			left = max(left, y)
	if bottom > top or left > right:
		print('0')
	else:
		print('1 ' + str(int(bottom)) + ' ' + str(int(right)))


T = int(input())
for t in range(T):
	R = int(input())
	minx = -10 ** 5
	maxx = 10 ** 5
	miny = -10 ** 5
	maxy = 10 ** 5
	for m in range(R):
		L = list(map(int, input().split()))
		if L[2] == 0:
			minx = max(minx, L[0])
		if L[4] == 0:
			maxx = min(maxx, L[0])
		if L[3] == 0:
			maxy = min(maxy, L[1])
		if L[5] == 0:
			miny = max(miny, L[1])
	if minx > maxx or miny > maxy:
		print(0)
	else:
		x = (maxx + minx) // 2
		y = (maxy + miny) // 2
		print(1, x, y)


q = int(input())
for Q in range(q):
	n = int(input())
	u = 10 ** 5
	d = -10 ** 5
	l = -10 ** 5
	r = 10 ** 5
	flag = True
	for i in range(n):
		(x, y, t1, t2, t3, t4) = map(int, input().split())
		u1 = y
		d1 = y
		l1 = x
		r1 = x
		if t1 == 1:
			l1 = -10 ** 5
		if t2 == 1:
			u1 = 10 ** 5
		if t3 == 1:
			r1 = 10 ** 5
		if t4 == 1:
			d1 = -10 ** 5
		if r < l1 or l > r1 or u1 < d or (u < d1):
			flag = False
		else:
			u = min(u, u1)
			d = max(d, d1)
			l = max(l, l1)
			r = min(r1, r)
	if flag == False:
		print(0)
	else:
		print(str(1) + ' ' + str(l) + ' ' + str(u))


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 i in range(q):
	n = int(input())
	(x1, x2, y1, y2) = (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:
			x2 = max(x2, x)
		if f2 == 0:
			y1 = min(y1, y)
		if f3 == 0:
			x1 = min(x1, x)
		if f4 == 0:
			y2 = max(y2, y)
	if x1 >= x2 and y1 >= y2:
		print(1, x1, y1)
	elif n == 1:
		print(1, x, y)
	else:
		print(0)


def f(q):
	mny = -10 ** 5
	mnx = -10 ** 5
	mxx = 10 ** 5
	mxy = 10 ** 5
	for (x, y, f1, f2, f3, f4) in q:
		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')
		print(mnx, mny)
	else:
		print('0')
for t in range(int(input())):
	q = []
	for i in range(int(input())):
		(x, y, f1, f2, f3, f4) = map(int, input().strip().split())
		q.append((x, y, f1, f2, f3, f4))
	f(q)


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)


for _ in range(int(input())):
	n = int(input())
	left = -10 ** 5
	right = 10 ** 5
	up = 10 ** 5
	down = -10 ** 5
	co = []
	for g in range(n):
		(x, y, l, u, r, d) = map(int, input().split())
		if g == 0:
			co.append(x)
			co.append(y)
		if not l:
			left = max(left, x)
		if not r:
			right = min(right, x)
		if not u:
			up = min(up, y)
		if not d:
			down = max(y, down)
	if left <= right and down <= up:
		print(1, right, up)
	else:
		print(0)


q = int(input())
for i in range(q):
	llimit = None
	rlimit = None
	dlimit = None
	ulimit = None
	n = int(input())
	r = []
	for j in range(n):
		(x, y, l, u, r, d) = map(int, input().split())
		if l == 0:
			llimit = x if llimit is None else max(llimit, x)
		if r == 0:
			rlimit = x if rlimit is None else min(rlimit, x)
		if d == 0:
			dlimit = y if dlimit is None else max(dlimit, y)
		if u == 0:
			ulimit = y if ulimit is None else min(ulimit, y)
	if llimit is None:
		llimit = rlimit
	if rlimit is None:
		rlimit = llimit
	if llimit is not None:
		if rlimit < llimit:
			print(0)
			continue
		x = llimit
	else:
		x = 0
	if dlimit is None:
		dlimit = ulimit
	if ulimit is None:
		ulimit = dlimit
	if dlimit is not None:
		if ulimit < dlimit:
			print(0)
			continue
		y = dlimit
	else:
		y = 0
	print(1, x, y)


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)


import sys
Input = lambda : map(int, sys.stdin.readline().split())

def check(x, y):
	if x[0] > x[1] or y[0] > y[1]:
		return 0
	return 1
for i in range(int(input())):
	n = int(input())
	x = [-float('inf'), float('inf')]
	y = [-float('inf'), float('inf')]
	Move = list()
	F = False
	for j in range(n):
		Move.append(list(Input()))
	for j in range(n):
		if Move[j][2] == 0:
			if Move[j][0] > x[0]:
				x[0] = Move[j][0]
			if check(x, y) == 0:
				print(0)
				F = True
				break
		if Move[j][3] == 0:
			if Move[j][1] < y[1]:
				y[1] = Move[j][1]
			if check(x, y) == 0:
				print(0)
				F = True
				break
		if Move[j][4] == 0:
			if Move[j][0] < x[1]:
				x[1] = Move[j][0]
			if check(x, y) == 0:
				print(0)
				F = True
				break
		if Move[j][5] == 0:
			if Move[j][1] > y[0]:
				y[0] = Move[j][1]
			if check(x, y) == 0:
				print(0)
				F = True
				break
	if F == False:
		print(1, end=' ')
		if x[0] == -float('inf'):
			if x[1] == float('inf'):
				print(0, end=' ')
			else:
				print(x[1], end=' ')
		elif x[1] == float('inf'):
			print(x[0], end=' ')
		else:
			print(x[0], end=' ')
		if y[0] == -float('inf'):
			if y[1] == float('inf'):
				print(0)
			else:
				print(y[1])
		elif y[1] == float('inf'):
			print(y[0])
		else:
			print(y[0])


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]))


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 *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
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))
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 zerolist(n):
	return [0] * n

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

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

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

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 bfs(g, st, lcatable, level):
	visited = [0] * len(g)
	visited[st] = 1
	queue = []
	queue.append(st)
	new = []
	while len(queue) != 0:
		s = queue.pop()
		new.append(s)
		for i in g[s]:
			if visited[i] == 0:
				level[i] = level[s] + 1
				lcatable[i][0] = s
				visited[i] = 1
				queue.append(i)
	return new

def lcatable(g, n, level):
	mx = 0
	while 2 ** mx <= n:
		mx += 1
	lcatable = [[-1] * mx for i in range(n + 1)]
	bfs(g, 1, lcatable, level)
	for j in range(1, mx):
		for i in range(1, n + 1):
			if lcatable[i][j - 1] != -1:
				lcatable[i][j] = lcatable[lcatable[i][j - 1]][j - 1]
	return lcatable

def dist(x0, y0, x1, y1):
	return abs(x0 - x1) + abs(y0 - y1)
ini = 10 ** 5

def solve():
	n = int(inp())
	info = []
	for i in range(n):
		temp = lis()
		info.append(temp)
	rtopleft = [-ini, ini]
	rbottomright = [ini, -ini]
	for i in range(n):
		topleft = [-ini, ini]
		bottomright = [ini, -ini]
		if info[i][2] == 0:
			topleft[0] = info[i][0]
		if info[i][3] == 0:
			topleft[1] = info[i][1]
		if info[i][4] == 0:
			bottomright[0] = info[i][0]
		if info[i][5] == 0:
			bottomright[1] = info[i][1]
		rtopleft[0] = max(rtopleft[0], topleft[0])
		rtopleft[1] = min(rtopleft[1], topleft[1])
		rbottomright[0] = min(rbottomright[0], bottomright[0])
		rbottomright[1] = max(rbottomright[1], bottomright[1])
	if rtopleft[0] > rbottomright[0] or rtopleft[1] < rbottomright[1]:
		print(0)
	else:
		print(1, rtopleft[0], rtopleft[1])
testcase(int(inp()))


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)


for _ in range(int(input())):
	(U, R) = (100000, 100000)
	(D, L) = (-100000, -100000)
	for _ in range(int(input())):
		(x, y, l, u, r, d) = map(int, input().split())
		if l == 0 and x > L:
			L = x
		if u == 0 and y < U:
			U = y
		if r == 0 and x < R:
			R = x
		if d == 0 and y > D:
			D = y
	if R < L or U < D:
		print(0)
	else:
		print(1, R, U)


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()


from sys import stdin, stdout
inf = int(100000.0)
input = stdin.readlines()
out = []
IN = 1
for q in range(int(input[0])):
	xl = -inf
	xr = inf
	yu = inf
	yd = -inf
	ans = True
	for IN in range(IN + 1, IN + int(input[IN]) + 1):
		(x, y, f1, f2, f3, f4) = map(int, input[IN].split())
		rxl = -inf
		rxr = inf
		ryu = inf
		ryd = -inf
		if not f1:
			rxl = x
		if not f2:
			ryu = y
		if not f3:
			rxr = x
		if not f4:
			ryd = y
		if rxl > xr or rxr < xl or ryu < yd or (ryd > yu):
			ans = False
		xl = max(xl, rxl)
		xr = min(xr, rxr)
		yu = min(yu, ryu)
		yd = max(yd, ryd)
	IN += 1
	if ans and xl <= xr and (yd <= yu):
		out.append('1 {} {}'.format(xl, yu))
	else:
		out.append('0')
print('\n'.join(out))


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

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

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

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return res

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(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

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
for _ in range(int(input())):
	n = int(input())
	cords = []
	fxs = []
	for __ in range(n):
		(x, y, left, up, right, down) = int_array()
		cords.append((x, y))
		fxs.append((left, up, right, down))
	(ltx, utx, rtx, dtx) = (NINF, INF, INF, NINF)
	for i in range(n):
		fx = fxs[i]
		c = cords[i]
		if not fx[0]:
			ltx = max(ltx, c[0])
		if not fx[1]:
			utx = min(utx, c[1])
		if not fx[2]:
			rtx = min(rtx, c[0])
		if not fx[3]:
			dtx = max(dtx, c[1])
	PP = int(100000.0)
	if ltx == NINF:
		ltx = -PP
	if rtx == INF:
		rtx = PP
	if utx == INF:
		utx = PP
	if dtx == NINF:
		dtx = -PP
	ans = ((ltx + rtx) // 2, (utx + dtx) // 2)
	if ltx <= rtx and dtx <= utx:
		print(*(1, ans[0], ans[1]))
	else:
		print(0)


q = int(input())
for w in range(q):
	n = int(input())
	x = []
	y = []
	f1 = []
	f2 = []
	f3 = []
	f4 = []
	for i in range(n):
		iarr = list(map(int, input().split()))
		x.append(iarr[0])
		y.append(iarr[1])
		f1.append(iarr[2])
		f3.append(iarr[3])
		f2.append(iarr[4])
		f4.append(iarr[5])
	lxr = 10 ** 5
	rxl = -10 ** 5
	lxu = 10 ** 5
	uxd = -10 ** 5
	for i in range(n):
		if f1[i] == 0:
			rxl = max(rxl, x[i])
		if f2[i] == 0:
			lxr = min(lxr, x[i])
		if f3[i] == 0:
			lxu = min(lxu, y[i])
		if f4[i] == 0:
			uxd = max(uxd, y[i])
	if rxl <= lxr and uxd <= lxu:
		print(1, (rxl + lxr) // 2, (uxd + lxu) // 2)
	else:
		print(0)


q = int(input())
for qq in range(q):
	n = int(input())
	mxx = 10 ** 5
	mxy = 10 ** 5
	mnx = -10 ** 5
	mny = -10 ** 5
	for nn in range(n):
		bot = input().split()
		x = int(bot[0])
		y = int(bot[1])
		p1 = int(bot[2])
		p2 = int(bot[3])
		p3 = int(bot[4])
		p4 = int(bot[5])
		if p1 == 0:
			mnx = max(mnx, x)
		if p2 == 0:
			mxy = min(mxy, y)
		if p3 == 0:
			mxx = min(mxx, x)
		if p4 == 0:
			mny = max(mny, y)
	if mnx > mxx or mny > mxy:
		print('0')
	else:
		print(1, mxx, mxy)


for _ in range(int(input())):
	n = int(input())
	a = []
	for i in range(n):
		a.append(list(map(int, input().split(' '))))
	xl = -10 ** 5
	xr = 10 ** 5
	for now in a:
		if now[4] == 0:
			xr = min(xr, now[0])
		if now[2] == 0:
			xl = max(xl, now[0])
	yd = -10 ** 5
	yu = 10 ** 5
	for now in a:
		if now[5] == 0:
			yd = max(yd, now[1])
		if now[3] == 0:
			yu = min(yu, now[1])
	if xl > xr or yd > yu:
		print(0)
	else:
		print(1, xl, yu)


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])


for _ in [0] * int(input()):
	r = [10 ** 5] * 4
	for _ in [0] * int(input()):
		(x, y, *f) = map(int, input().split())
		r = [(min(u, v), u)[w] for (u, v, w) in zip(r, (-x, y, x, -y), f)]
	print(*([1, r[2], r[1]], [0])[-r[0] > r[2] or -r[3] > r[1]])


q = int(input())
import math

def convert(robot):
	(x, y, f1, f2, f3, f4) = robot
	cur = [x, x, y, y]
	if f1:
		cur[0] = -math.inf
	if f2:
		cur[2] = math.inf
	if f3:
		cur[1] = math.inf
	if f4:
		cur[3] = -math.inf
	return cur

def intersect(area0, area1):
	(l0, r0, u0, d0) = area0
	(l1, r1, u1, d1) = area1
	if l0 > r1 or l1 > r0:
		return None
	if u0 < d1 or u1 < d0:
		return None
	return (max(l1, l0), min(r0, r1), min(u0, u1), max(d0, d1))

def extract(area):
	(l, r, u, d) = area
	(x, y) = (None, None)
	if l == -math.inf:
		x = r if r != math.inf else 0
	else:
		x = l if l != -math.inf else r
	if u == math.inf:
		y = d if d != -math.inf else 0
	else:
		y = u if u != math.inf else d
	return [x, y]

def solve(r):
	cur = [-math.inf, math.inf, math.inf, -math.inf]
	for robot in r:
		area = convert(robot)
		cur = intersect(cur, area)
		if cur == None:
			return (0, [])
	return (1, extract(cur))
for _ in range(q):
	N = int(input())
	r = []
	for n in range(N):
		r.append(list(map(int, input().split())))
	(p, q) = solve(r)
	print(' '.join(map(str, [p] + q)))


from typing import Optional, Tuple

class Robot:
	x: int
	y: int
	left: bool
	top: bool
	right: bool
	down: bool
MAX_VAL = 100000

class Scope:

	def __init__(self):
		self.x_range_min = -MAX_VAL
		self.x_range_max = MAX_VAL
		self.y_range_min = -MAX_VAL
		self.y_range_max = MAX_VAL

	def reduce_scope(self, robot: Robot) -> None:
		if not robot.left:
			self.x_range_min = max(self.x_range_min, robot.x)
		if not robot.right:
			self.x_range_max = min(self.x_range_max, robot.x)
		if not robot.top:
			self.y_range_max = min(self.y_range_max, robot.y)
		if not robot.down:
			self.y_range_min = max(self.y_range_min, robot.y)

	def get_a_solution(self) -> Optional[Tuple[int, int]]:
		if self.x_range_max >= self.x_range_min and self.y_range_max >= self.y_range_min:
			return (self.x_range_max, self.y_range_max)
		return None
t = int(input())
for i in range(t):
	n = int(input())
	scope = Scope()
	for r_n in range(n):
		values = [int(i) for i in input().split()]
		r = Robot()
		(r.x, r.y, r.left, r.top, r.right, r.down) = values
		scope.reduce_scope(r)
	sol = scope.get_a_solution()
	if sol is None:
		print(0)
	else:
		print(1, *sol)


import sys
import os
from io import IOBase, BytesIO

def main():
	for tc in range(int(input())):
		n = int(input())
		arr = [0] * n
		for i in range(n):
			arr[i] = get_array()
		(x1, y1) = (-10 ** 5 - 1, -10 ** 5 - 1)
		(x2, y2) = (10 ** 5 + 1, 10 ** 5 + 1)
		f = 0
		for i in range(n):
			if arr[i][3] == 0:
				f = 1
				y2 = min(y2, arr[i][1])
			if arr[i][2] == 0:
				f = 1
				x1 = max(x1, arr[i][0])
			if arr[i][4] == 0:
				f = 1
				x2 = min(x2, arr[i][0])
			if arr[i][5] == 0:
				f = 1
				y1 = max(y1, arr[i][1])
		if f == 0:
			print(1, 1, 1)
			continue
		if y1 > y2 or x1 > x2:
			print(0)
		else:
			print(1, end=' ')
			if x1 == -10 ** 5 - 1 and x2 == 10 ** 5 + 1:
				print(0, end=' ')
			elif x1 != -10 ** 5 - 1:
				print(x1, end=' ')
			else:
				print(x2, end=' ')
			if y1 == -10 ** 5 - 1 and y2 == 10 ** 5 + 1:
				print(0, end=' ')
			elif y1 != -10 ** 5 - 1:
				print(y1, end=' ')
			else:
				print(y2, end=' ')
			print()
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		py2 = round(0.5)
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2 == 1:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			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))

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

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

def input():
	return sys.stdin.readline().strip()
main()


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)


for _ in range(int(input())):
	n = int(input())
	l = []
	r = []
	min_x = int(-100000.0)
	min_y = int(-100000.0)
	max_x = int(100000.0)
	max_y = int(100000.0)
	for i in range(n):
		z = list(map(int, input().split(' ')))
		r.append(z)
		if z[2:] != [1, 1, 1, 1]:
			l.append(z)
			if not z[2]:
				min_x = max(min_x, z[0])
			if not z[3]:
				max_y = min(max_y, z[1])
			if not z[4]:
				max_x = min(max_x, z[0])
			if not z[5]:
				min_y = max(min_y, z[1])
	if not l:
		print(1, r[0][0], r[0][1])
	else:
		ans = 1
		if min_x > max_x:
			ans = 0
		if max_y < min_y:
			ans = 0
		if ans:
			print(1, min_x, min_y)
		else:
			print(0)


import sys
input = sys.stdin.readline
from bisect import *
q = int(input())
for _ in range(q):
	n = int(input())
	robot = [tuple(map(int, input().split())) for _ in range(n)]
	robot.sort(key=lambda k: k[0])
	x = [x for (x, _, _, _, _, _) in robot]
	xs = set(x)
	(l_acc, r_acc) = ([0], [0])
	for (_, _, f1, _, f3, _) in robot:
		l_acc.append(l_acc[-1] + f1)
		r_acc.append(r_acc[-1] + f3)
	for xi in xs:
		mark1 = bisect_left(x, xi)
		mark2 = bisect_right(x, xi)
		if r_acc[mark1] + l_acc[n] - l_acc[mark2] == n - (mark2 - mark1):
			ans_x = xi
			break
	else:
		print(0)
		continue
	robot.sort(key=lambda k: k[1])
	y = [y for (_, y, _, _, _, _) in robot]
	ys = set(y)
	(u_acc, d_acc) = ([0], [0])
	for (_, _, _, f2, _, f4) in robot:
		u_acc.append(u_acc[-1] + f2)
		d_acc.append(d_acc[-1] + f4)
	for yi in ys:
		mark1 = bisect_left(y, yi)
		mark2 = bisect_right(y, yi)
		if u_acc[mark1] + d_acc[n] - d_acc[mark2] == n - (mark2 - mark1):
			ans_y = yi
			break
	else:
		print(0)
		continue
	print(1, ans_x, ans_y)


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)


import os
import gc
import sys
from io import BytesIO, IOBase
from collections import Counter
from collections import deque
import heapq
import math
import statistics

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
MAX = float('inf')
MIN = float('-inf')
MOD = 10 ** 9 + 7

def readTree(n, m):
	adj = [deque([]) for _ in range(n + 1)]
	for _ in range(m):
		(u, v) = ain()
		adj[u].append(v)
		adj[v].append(u)
	return adj

def solve(n):
	xr = [MIN, MAX]
	yr = [MIN, MAX]
	r = deque([])
	for _ in range(n):
		r.append(ain())
	for i in r:
		(x, y, f1, f2, f3, f4) = i
		xri = ['', '']
		yri = ['', '']
		if f1 == 1:
			xri[0] = MIN
		else:
			xri[0] = x
		if f3 == 1:
			xri[1] = MAX
		else:
			xri[1] = x
		if xr[0] > xri[1]:
			return -1
		if xr[1] < xri[0]:
			return -1
		xr[0] = max(xr[0], xri[0])
		xr[1] = min(xr[1], xri[1])
		if f2 == 1:
			yri[1] = MAX
		else:
			yri[1] = y
		if f4 == 1:
			yri[0] = MIN
		else:
			yri[0] = y
		if yr[0] > yri[1]:
			return -1
		if yr[1] < yri[0]:
			return -1
		yr[0] = max(yr[0], yri[0])
		yr[1] = min(yr[1], yri[1])
	return (xr, yr)

def main():
	for _ in range(iin()):
		n = iin()
		ans = solve(n)
		if ans == -1:
			print(0)
		else:
			print(1, end=' ')
			(xr, yr) = ans
			if xr[0] != MIN:
				print(xr[0], end=' ')
			elif xr[1] != MAX:
				print(xr[1], end=' ')
			else:
				print(0, end=' ')
			if yr[0] != MIN:
				print(yr[0])
			elif yr[1] != MAX:
				print(yr[1])
			else:
				print(0)
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()


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))


numOfQuestions = int(input())
for i in range(numOfQuestions):
	numOfRobots = int(input())
	flag = 0
	kx1 = -100000
	ky1 = -100000
	kx2 = 100000
	ky2 = 100000
	for j in range(numOfRobots):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		if f1 == 0:
			kx1 = max(kx1, x)
		if f2 == 0:
			ky2 = min(ky2, y)
		if f3 == 0:
			kx2 = min(kx2, x)
		if f4 == 0:
			ky1 = max(ky1, y)
	if kx1 > kx2 or ky2 < ky1:
		print(0)
	else:
		coordinate1 = kx1
		coordinate2 = ky2
		print(1, coordinate1, coordinate2)


import sys
MAXN = 100005
MAX = 100000
q = 0
n = 0
pos = [[0, 0] for _ in range(MAXN)]
dirs = [[0, 0, 0, 0] for _ in range(MAXN)]
hx = [-1, 0, 1, 0]
hy = [0, 1, 0, -1]
rect = [[0, 0, 0, 0] for _ in range(MAXN)]

def intersect(r1, r2):
	ret = [0, 0, 0, 0]
	ret[0] = min(r1[0], r2[0])
	ret[1] = max(r1[1], r2[1])
	ret[2] = max(r1[2], r2[2])
	ret[3] = min(r1[3], r2[3])
	if ret[0] < ret[2] or ret[1] > ret[3]:
		return None
	return ret

def solve():
	n = int(input())
	for i in range(n):
		temp = input().split(' ')
		pos[i][0] = int(temp[0])
		pos[i][1] = int(temp[1])
		for j in range(4):
			dirs[i][j] = int(temp[j + 2])
	for i in range(n):
		rect[i][0] = pos[i][0]
		rect[i][1] = pos[i][1]
		rect[i][2] = pos[i][0]
		rect[i][3] = pos[i][1]
		if dirs[i][0] == 1:
			rect[i][2] = -MAX
		if dirs[i][1] == 1:
			rect[i][3] = MAX
		if dirs[i][2] == 1:
			rect[i][0] = MAX
		if dirs[i][3] == 1:
			rect[i][1] = -MAX
	cur_rect = rect[0]
	for i in range(1, n):
		cur_rect = intersect(cur_rect, rect[i])
		if cur_rect == None:
			print(0)
			return
	print(f'1 {cur_rect[0]} {cur_rect[1]}')
q = int(input())
for _ in range(q):
	solve()


for _ in range(int(input())):
	bounds = [-100000, 100000, 100000, -100000]
	for j in range(int(input())):
		data = [int(i) for i in input().split()]
		for d in range(4):
			if data[d + 2] == 0:
				if d == 1 or d == 2:
					bounds[d] = min(data[d % 2], bounds[d])
				else:
					bounds[d] = max(data[d % 2], bounds[d])
	if bounds[0] <= bounds[2] and bounds[3] <= bounds[1]:
		print(1, bounds[0], bounds[1])
	else:
		print(0)


for _ in range(int(input())):
	n = int(input())
	coord = []
	(xlmax, xrmax, ytmax, ybmax) = (-100000, 100000, 100000, -100000)
	for i in range(n):
		(xl, xr, yt, yb) = (-100000, 100000, 100000, -100000)
		val = list(map(int, input().split(' ')))
		if val[2] == 0:
			xl = val[0]
			if xl > xlmax:
				xlmax = xl
		if val[3] == 0:
			yt = val[1]
			if yt < ytmax:
				ytmax = yt
		if val[4] == 0:
			xr = val[0]
			if xr < xrmax:
				xrmax = xr
		if val[5] == 0:
			yb = val[1]
			if yb > ybmax:
				ybmax = yb
	if xlmax <= xrmax and ybmax <= ytmax:
		x = (xlmax + xrmax) // 2
		y = (ytmax + ybmax) // 2
		print(1, x, y)
	else:
		print(0)


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)


q = int(input())
inf = 10 ** 5
for t in range(q):
	n = int(input())
	l = -inf
	r = inf
	d = -inf
	u = inf
	for m in range(n):
		(x, y, *p) = [int(e) for e in input().split()]
		if p[0] == 0:
			l = max(l, x)
		if p[1] == 0:
			u = min(u, y)
		if p[2] == 0:
			r = min(r, x)
		if p[3] == 0:
			d = max(d, y)
	if l > r or d > u:
		print(0)
	else:
		print(1, (l + r) // 2, (d + u) // 2)


def get_ans(array_of_robots):
	x_plus_limit = 10 ** 5
	x_minus_limit = -10 ** 5
	y_plus_limit = 10 ** 5
	y_mimus_limit = -10 ** 5
	for array in array_of_robots:
		x_plus_limit = min(x_plus_limit, array[0] + array[4] * 2 * 10 ** 5)
		x_minus_limit = max(x_minus_limit, array[0] - array[2] * 2 * 10 ** 5)
		y_plus_limit = min(y_plus_limit, array[1] + array[3] * 2 * 10 ** 5)
		y_mimus_limit = max(y_mimus_limit, array[1] - array[5] * 2 * 10 ** 5)
	if x_plus_limit < x_minus_limit or y_plus_limit < y_mimus_limit:
		print(0)
	else:
		print(1, x_plus_limit, y_plus_limit)
q = int(input())
for i in range(q):
	n = int(input())
	array_of_robots = []
	for j in range(n):
		array = list(map(int, input().strip().split()))
		array_of_robots.append(array)
	get_ans(array_of_robots)


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])


from copy import deepcopy
from bisect import bisect_right
from itertools import combinations
from sys import stdin

def left():
	return 1 + 1

def right():
	return 1 + 3

def down():
	return 1 + 2

def up():
	return 1 + 4

def reachable(point, robot, t):
	if t == 1:
		for i in range(len(robot)):
			if robot[i][0] == point or (robot[i][0] > point and robot[i][left()] == 1):
				pass
			else:
				return False
		else:
			return True
	elif t == 2:
		for i in range(len(robot)):
			if robot[i][1] == point or (robot[i][1] < point and robot[i][down()] == 1):
				pass
			else:
				return False
		else:
			return True
	elif t == 3:
		for i in range(len(robot)):
			if robot[i][0] == point or (robot[i][0] > point and robot[i][right()] == 1):
				pass
			else:
				return False
		else:
			return True
	else:
		for i in range(len(robot)):
			if robot[i][1] == point or (robot[i][1] > point and robot[i][up()] == 1):
				pass
			else:
				return False
		else:
			return True
q = int(stdin.readline().strip())
for _ in range(q):
	n = int(stdin.readline().strip())
	robot = []
	for _ in range(n):
		robot.append(list(map(int, stdin.readline().split())))
	xl = -10 ** 5
	xr = 10 ** 5
	yt = 10 ** 5
	yb = -10 ** 5
	flag = True
	for i in range(n - 1):
		if robot[i][0] != robot[i + 1][0] or robot[i][1] != robot[i + 1][1]:
			flag = False
			break
	if flag == True:
		print(1, robot[0][0], robot[0][1])
		continue
	for i in range(n):
		if robot[i][2] == 0:
			if xl < robot[i][0]:
				xl = robot[i][0]
		if robot[i][4] == 0:
			if xr > robot[i][0]:
				xr = robot[i][0]
		if robot[i][3] == 0:
			if yt > robot[i][1]:
				yt = robot[i][1]
		if robot[i][5] == 0:
			if yb < robot[i][1]:
				yb = robot[i][1]
	if xl > xr or yt < yb:
		print(0)
		continue
	else:
		print(1, (xl + xr) // 2, (yt + yb) // 2)


import sys
from collections import Counter

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(INT()):
	N = INT()
	L = D = -INF
	R = U = INF
	for _ in range(N):
		(x, y, l, u, r, d) = MAP()
		if not l:
			L = max(L, x)
		if not u:
			U = min(U, y)
		if not r:
			R = min(R, x)
		if not d:
			D = max(D, y)
	if L > R or D > U:
		print(0)
		continue
	ans = [0] * 3
	ans[0] = 1
	if L == -INF and R == INF:
		ans[1] = 0
	elif L == -INF:
		ans[1] = R
	else:
		ans[1] = L
	if D == -INF and U == INF:
		ans[2] = 0
	elif D == -INF:
		ans[2] = U
	else:
		ans[2] = D
	print(*ans)


def solve1d(a0, a1):
	if len(a0) == 0:
		if len(a1) == 0:
			return (True, 0)
		return (True, min(a1))
	if len(a1) == 0:
		return (True, max(a0))
	m = min(a1)
	M = max(a0)
	if M > m:
		return (False, 0)
	return (True, m)
q = int(input())
for i in range(q):
	n = int(input())
	y0 = []
	y1 = []
	x0 = []
	x1 = []
	for j in range(n):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		if f1 == 0:
			x0.append(x)
		if f2 == 0:
			y1.append(y)
		if f3 == 0:
			x1.append(x)
		if f4 == 0:
			y0.append(y)
	(tx, x) = solve1d(x0, x1)
	(ty, y) = solve1d(y0, y1)
	if not tx or not ty:
		print(0)
	else:
		print(1, x, y)


q = int(input())
for _ in range(q):
	n = int(input())
	a = [list(map(int, input().split())) for _ in range(n)]
	f = True
	right = 10 ** 5
	left = -10 ** 5
	up = 10 ** 5
	under = -10 ** 5
	for k in range(n):
		cnt = 0
		for i in range(2, 6):
			if a[k][i] == 0:
				if i == 2:
					left = max(a[k][0], left)
					if left > right:
						print(0)
						f = False
						break
				if i == 3:
					up = min(a[k][1], up)
					if up < under:
						print(0)
						f = False
						break
				if i == 4:
					right = min(a[k][0], right)
					if right < left:
						print(0)
						f = False
						break
				if i == 5:
					under = max(a[k][1], under)
					if under > up:
						print(0)
						f = False
						break
		if f == False:
			break
	if f == False:
		continue
	print(1, right, up)


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')


t = int(input())
for _ in range(t):
	zt = [-10 ** 5, 10 ** 5, 10 ** 5, -10 ** 5]
	n = int(input())
	l = []
	for i in range(n):
		l.append(list(map(int, input().split())))
	for i in range(n):
		if l[i][2] == 0:
			zt[0] = max(l[i][0], zt[0])
		if l[i][3] == 0:
			zt[1] = min(l[i][1], zt[1])
		if l[i][4] == 0:
			zt[2] = min(l[i][0], zt[2])
		if l[i][5] == 0:
			zt[3] = max(l[i][1], zt[3])
	if zt[2] >= zt[0] and zt[1] >= zt[3]:
		print(1, zt[0], zt[1])
	else:
		print(0)


import os
import sys
debug = True
if debug and os.path.exists('input.in'):
	input = open('input.in', 'r').readline
else:
	debug = False
	input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())
test_count = int(input())
for t in range(test_count):
	if debug:
		print('Test Case #', t + 1)
	n = inp()
	left = -100000
	right = 100000
	top = 100000
	bottom = -100000
	for _ in range(n):
		(x, y, a, b, c, d) = invr()
		if a == 0:
			left = max(left, x)
		if b == 0:
			top = min(top, y)
		if c == 0:
			right = min(right, x)
		if d == 0:
			bottom = max(bottom, y)
	if left > right or bottom > top:
		print(0)
	else:
		print(1, left, top)


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])


import collections
import math
t = int(input())
for _ in range(t):
	n = int(input())
	limits = [[float('-inf'), float('+inf')], [float('-inf'), float('+inf')]]
	for __ in range(n):
		a = [int(x) for x in input().split()]
		if a[2] == 0:
			limits[0][0] = max(limits[0][0], a[0])
		if a[3] == 0:
			limits[1][1] = min(limits[1][1], a[1])
		if a[4] == 0:
			limits[0][1] = min(limits[0][1], a[0])
		if a[5] == 0:
			limits[1][0] = max(limits[1][0], a[1])
	if limits[0][0] > limits[0][1] or limits[1][0] > limits[1][1]:
		print('0')
	else:
		if limits[0][0] == float('-inf'):
			if limits[0][1] == float('+inf'):
				limits[0][0] = 0
			else:
				limits[0][0] = limits[0][1]
		if limits[1][0] == float('-inf'):
			if limits[1][1] == float('+inf'):
				limits[1][0] = 0
			else:
				limits[1][0] = limits[1][1]
		print('1 %s %s' % (limits[0][0], limits[1][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)


INF = 100000
for case in range(int(input())):
	n = int(input())
	lim = [-INF, INF, INF, -INF]
	for i in range(n):
		f = list(map(int, input().split()))
		(x, y, f) = (f[0], f[1], f[2:])
		cur = [-INF, INF, INF, -INF]
		for j in range(4):
			if not f[j]:
				cur[j] = y if j & 1 else x
		lim = (max(lim[0], cur[0]), min(lim[1], cur[1]), min(lim[2], cur[2]), max(lim[3], cur[3]))
	print(' '.join(map(str, [1, lim[0], lim[1]])) if lim[0] <= lim[2] and lim[1] >= lim[3] else '0')


T = int(input())
for t in range(T):
	N = int(input())
	x = -100000
	X = 100000
	y = -100000
	Y = 100000
	for n in range(N):
		L = list(map(int, input().split()))
		if L[2] == 0:
			x = max(x, L[0])
		if L[4] == 0:
			X = min(X, L[0])
		if L[3] == 0:
			Y = min(Y, L[1])
		if L[5] == 0:
			y = max(y, L[1])
	if x > X or y > Y:
		print(0)
	else:
		a = (X + x) // 2
		b = (Y + y) // 2
		print(1, a, b)


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())
q = []
for _ in range(Q):
	N = int(input())
	X = []
	Y = []
	Xd = []
	Yd = []
	for _ in range(N):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		X.append(x)
		Y.append(y)
		Xd.append([f1, f3])
		Yd.append([f4, f2])
	q.append([N, X, Y, Xd, Yd])
for qq in q:
	(N, X, Y, Xd, Yd) = qq
	ans = 1
	r = max(X)
	l = min(X)
	com = False
	for (i, x) in enumerate(X):
		if Xd[i][0] == 0:
			l = max(x, l)
		if Xd[i][1] == 0:
			r = min(x, r)
		if l > r:
			ans = 0
			break
		elif l == r:
			if not com:
				ax = l
				com = True
				continue
			if l != ax:
				ans = 0
				break
	ax = l
	r = max(Y)
	l = min(Y)
	com = False
	for (i, y) in enumerate(Y):
		if Yd[i][0] == 0:
			l = max(y, l)
		if Yd[i][1] == 0:
			r = min(y, r)
		if l > r:
			ans = 0
			break
		elif l == r:
			if not com:
				ay = l
				com = True
				continue
			if l != ay:
				ans = 0
				break
	ay = l
	if ans == 0:
		print(ans)
	else:
		print(ans, ax, ay)


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)


t = int(input())
for T in range(t):
	n = int(input())
	ymax = 10 ** 5
	xmax = 10 ** 5
	ymin = -1 * 10 ** 5
	xmin = -1 * 10 ** 5
	for i in range(n):
		a = list(map(int, input().split()))
		if a[2] == 0:
			xmin = max(xmin, a[0])
		if a[3] == 0:
			ymax = min(ymax, a[1])
		if a[4] == 0:
			xmax = min(xmax, a[0])
		if a[5] == 0:
			ymin = max(ymin, a[1])
	if xmin <= xmax and ymax >= ymin:
		print(1, xmax, ymax)
	else:
		print(0)


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])


class CodeforcesTask1196CSolution:

	def __init__(self):
		self.result = ''
		self.q = 0
		self.queries = []

	def read_input(self):
		self.q = int(input())
		for x in range(self.q):
			n = int(input())
			query = []
			for y in range(n):
				query.append([int(z) for z in input().split(' ')])
			self.queries.append(query)

	def process_task(self):
		results = []
		for query in self.queries:
			(top, bottom, left, right) = (None, None, None, None)
			for robot in query:
				if not robot[2]:
					if left is None:
						left = robot[0]
					else:
						left = max(left, robot[0])
				if not robot[3]:
					if top is None:
						top = robot[1]
					else:
						top = min(top, robot[1])
				if not robot[4]:
					if right is None:
						right = robot[0]
					else:
						right = min(right, robot[0])
				if not robot[5]:
					if bottom is None:
						bottom = robot[1]
					else:
						bottom = max(bottom, robot[1])
			if top is None:
				if bottom is None:
					top = 0
					bottom = 0
				else:
					top = bottom
			elif bottom is None:
				bottom = top
			if left is None:
				if right is None:
					left = 0
					right = 0
				else:
					left = right
			elif right is None:
				right = left
			if top >= bottom and right >= left:
				results.append('1 {1} {0}'.format(top, left))
			else:
				results.append('0')
		self.result = '\n'.join(results)

	def get_result(self):
		return self.result
Solution = CodeforcesTask1196CSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


def answer():
	limit_x_up = 10 ** 5
	limit_x_down = -10 ** 5
	limit_y_up = 10 ** 5
	limit_y_down = -10 ** 5
	n = int(input())
	for i in range(n):
		(x, y, can_x_down, can_y_up, can_x_up, can_y_down) = map(int, input().split(' '))
		if can_x_down == 0:
			limit_x_down = max(x, limit_x_down)
		if can_x_up == 0:
			limit_x_up = min(x, limit_x_up)
		if can_y_down == 0:
			limit_y_down = max(y, limit_y_down)
		if can_y_up == 0:
			limit_y_up = min(y, limit_y_up)
	if limit_x_up >= limit_x_down and limit_y_up >= limit_y_down:
		out = '1 %d %d' % (limit_x_up, limit_y_up)
	else:
		out = '0'
	return out
for _ in range(int(input())):
	out = answer()
	print(out)


from sys import stdin
input = stdin.readline
inf = 10 ** 5
for i in range(int(input())):
	n = int(input())
	robots = []
	u = r = inf
	d = l = -inf
	for i in range(n):
		ro = list(map(int, input().split()))
		(x, y, f1, f2, f3, f4) = ro
		if not f1:
			l = max(l, x)
		if not f2:
			u = min(u, y)
		if not f3:
			r = min(r, x)
		if not f4:
			d = max(d, y)
	if u >= d and r >= l:
		print(1, r, u)
	else:
		print(0)


from sys import stdin
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	coord = []
	(xlmax, xrmax, ytmax, ybmax) = (-100000, 100000, 100000, -100000)
	for i in range(n):
		(xl, xr, yt, yb) = (-100000, 100000, 100000, -100000)
		val = list(map(int, stdin.readline().split(' ')))
		if val[2] == 0:
			xl = val[0]
			if xl > xlmax:
				xlmax = xl
		if val[3] == 0:
			yt = val[1]
			if yt < ytmax:
				ytmax = yt
		if val[4] == 0:
			xr = val[0]
			if xr < xrmax:
				xrmax = xr
		if val[5] == 0:
			yb = val[1]
			if yb > ybmax:
				ybmax = yb
	if xlmax <= xrmax and ybmax <= ytmax:
		x = (xlmax + xrmax) // 2
		y = (ytmax + ybmax) // 2
		print(1, x, y)
	else:
		print(0)


from collections import deque
import sys

def inp():
	return sys.stdin.readline().strip()
for _ in range(int(inp())):
	up = 10 ** 5
	down = -10 ** 5
	left = -10 ** 5
	right = 10 ** 5
	f = True
	n = int(inp())
	for i in range(n):
		(x, y, f1, f2, f3, f4) = map(int, inp().split())
		if f1 == 0:
			if right < x:
				f = False
			left = max(left, x)
		if f2 == 0:
			if down > y:
				f = False
			up = min(up, y)
		if f3 == 0:
			if left > x:
				f = False
			right = min(right, x)
		if f4 == 0:
			if up < y:
				f = False
			down = max(down, y)
	if up < down or left > right:
		f = False
	if f:
		print(1, left, up)
	else:
		print(0)


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))


import sys
input = sys.stdin.buffer.readline
q = int(input())
for _ in range(q):
	n = int(input())
	L = [0] * n
	for i in range(n):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		L[i] = (x, y, f1, f2, f3, f4)
	minX = -10 ** 5
	maxX = 10 ** 5
	minY = -10 ** 5
	maxY = 10 ** 5
	for i in range(n):
		(x, y, f1, f2, f3, f4) = L[i]
		if f1 == 0:
			if maxX < x:
				print(0)
				break
			else:
				minX = max(minX, x)
		if f2 == 0:
			if minY > y:
				print(0)
				break
			else:
				maxY = min(maxY, y)
		if f3 == 0:
			if minX > x:
				print(0)
				break
			else:
				maxX = min(maxX, x)
		if f4 == 0:
			if maxY < y:
				print(0)
				break
			else:
				minY = max(minY, y)
	else:
		if maxX >= minX and maxY >= minY:
			print(1, maxX, maxY)
		else:
			print(0)


import math

class Read:

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(sep=' '):
		return input().split(sep)

	@staticmethod
	def list_int(sep=' '):
		return list(map(int, input().split(sep)))

def solve():
	n = Read.int()
	max_x = 10 ** 5
	min_x = -10 ** 5
	max_y = 10 ** 5
	min_y = -10 ** 5
	for a in range(n):
		t = Read.list_int()
		if t[2] == 0 and min_x < t[0]:
			min_x = t[0]
		if t[3] == 0 and max_y > t[1]:
			max_y = t[1]
		if t[4] == 0 and max_x > t[0]:
			max_x = t[0]
		if t[5] == 0 and min_y < t[1]:
			min_y = t[1]
	if min_y > max_y or min_x > max_x:
		print('0')
	else:
		print('1 {} {}'.format(max_x, max_y))
query_count = Read.int()
for j in range(query_count):
	solve()


inf = 100000
for q in range(int(input())):
	n = int(input())
	(l, u, r, d) = (-inf, inf, inf, -inf)
	for i in range(n):
		(x, y, f1, f2, f3, f4) = list(map(int, input().split()))
		if f1 == 0:
			l = max(l, x)
		if f2 == 0:
			u = min(u, y)
		if f3 == 0:
			r = min(r, x)
		if f4 == 0:
			d = max(d, y)
	if d > u or l > r:
		print(0)
	else:
		print(1, l, d)


for _ in range(int(input())):
	n = int(input())
	a = [[*map(int, input().split())] for _ in range(n)]
	x1 = y1 = -100000
	x2 = y2 = 100000
	for i in a:
		if i[2] and i[4]:
			continue
		elif i[2]:
			x2 = min(x2, i[0])
		elif i[4]:
			x1 = max(x1, i[0])
		else:
			x1 = max(x1, i[0])
			x2 = min(x2, i[0])
	for i in a:
		if i[3] and i[5]:
			continue
		elif i[3]:
			y1 = max(y1, i[1])
		elif i[5]:
			y2 = min(y2, i[1])
		else:
			y1 = max(y1, i[1])
			y2 = min(y2, i[1])
	if x1 > x2 or y1 > y2:
		print(0)
	else:
		print(1, (x1 + x2) // 2, (y1 + y2) // 2)


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)


q = int(input())
for _ in range(q):
	n = int(input())
	A = []
	for z in range(n):
		a = list(map(int, input().split()))
		A.append(a)
	lhl = -10 ** 5
	rhl = 10 ** 5
	uhl = 10 ** 5
	bhl = -10 ** 5
	for i in A:
		if i[2] == 0:
			lhl = max(lhl, i[0])
		if i[3] == 0:
			uhl = min(uhl, i[1])
		if i[4] == 0:
			rhl = min(rhl, i[0])
		if i[5] == 0:
			bhl = max(bhl, i[1])
	if lhl <= rhl and uhl >= bhl:
		print(1, lhl, uhl)
	else:
		print(0)


for t in range(int(input())):
	n = int(input())
	(l, r, u, d) = (-10 ** 5, 10 ** 5, 10 ** 5, -10 ** 5)
	for i in range(n):
		(x, y, a, b, c, D) = map(int, input().split())
		if a == 0:
			l = max(l, x)
		if b == 0:
			u = min(u, y)
		if c == 0:
			r = min(r, x)
		if D == 0:
			d = max(d, y)
	if l > r or d > u:
		print(0)
	else:
		print(1, l, u)


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)


import sys
from sys import stdin, stdout
import bisect
import math
import heapq

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
import math

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def main():
	t = inin()
	for _ in range(t):
		n = inin()
		x1 = 100000
		y1 = 100000
		x2 = -100000
		y2 = -100000
		for i in range(n):
			(a, b, c, d, e, f) = cin()
			if c == 0:
				x2 = max(x2, a)
			if d == 0:
				y1 = min(y1, b)
			if e == 0:
				x1 = min(x1, a)
			if f == 0:
				y2 = max(y2, b)
		if x1 >= x2 and y1 >= y2:
			if x1 >= -100000:
				x2 = x1
			if y1 >= -100000:
				y2 = y1
			print(1, x2, y2)
		else:
			print(0)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			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 sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


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)


for _ in [0] * int(input()):
	r = [10 ** 5] * 4
	for _ in [0] * int(input()):
		(x, y, *f) = map(int, input().split())
		a = (-x, y, x, -y)
		for i in (0, 1, 2, 3):
			if f[i] < 1:
				r[i] = min(r[i], a[i])
	print(*([1, r[2], r[1]], [0])[-r[0] > r[2] or -r[3] > r[1]])


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)


from sys import stdin
from collections import *

def arr_inp(n):
	if n == 1:
		return [int(x) for x in stdin.readline().split()]
	elif n == 2:
		return [float(x) for x in stdin.readline().split()]
	else:
		return list(stdin.readline()[:-1])
for i in range(int(input())):
	(n, coor, flag) = (int(input()), [-10 ** 5, 10 ** 5, 10 ** 5, -10 ** 5], 0)
	for j in range(n):
		a = arr_inp(1)
		coor2 = [-10 ** 5, 10 ** 5]
		if not a[2]:
			coor2[0] = a[0]
		if not a[4]:
			coor2[1] = a[0]
		(coor[0], coor[1]) = (max(coor[0], coor2[0]), min(coor[1], coor2[1]))
		coor2 = [10 ** 5, -10 ** 5]
		if not a[3]:
			coor2[0] = a[1]
		if not a[5]:
			coor2[1] = a[1]
		(coor[2], coor[3]) = (min(coor[2], coor2[0]), max(coor[3], coor2[1]))
	if coor[0] > coor[1] or coor[2] < coor[3]:
		print(0)
	else:
		print(1, coor[1], coor[2])


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)


a = int(input())
coord = []
import math
for i in range(a):
	q = int(input())
	lmax = -math.inf
	rmin = math.inf
	umin = math.inf
	dmax = -math.inf
	coord = []
	for i in range(q):
		z = list(map(int, input().split()))
		x = z[0]
		y = z[1]
		point = [-math.inf, math.inf, -math.inf, math.inf]
		if z[2] == 0:
			point[0] = x
		if z[3] == 0:
			point[3] = y
		if z[4] == 0:
			point[1] = x
		if z[5] == 0:
			point[2] = y
		coord.append(point)
		lmax = max(coord[-1][0], lmax)
		rmin = min(coord[-1][1], rmin)
		dmax = max(coord[-1][2], dmax)
		umin = min(coord[-1][3], umin)
	if lmax > rmin or dmax > umin:
		print(0)
		continue
	else:
		ans = [-1, -1]
		if lmax == -math.inf:
			if rmin == math.inf:
				ans[0] = 0
			else:
				ans[0] = rmin
		else:
			ans[0] = lmax
		if dmax == -math.inf:
			if umin == math.inf:
				ans[1] = 0
			else:
				ans[1] = umin
		else:
			ans[1] = dmax
		print(1, end=' ')
		print(*ans)


q = int(input())
result = []
for _ in range(q):
	n = int(input())
	x_max = y_max = 10 ** 5
	x_min = y_min = -1 * 10 ** 5
	for _ in range(n):
		(x, y, f1, f2, f3, f4) = map(int, input().split())
		if f1 == 0:
			if x_min < x:
				x_min = x
		if f2 == 0:
			if y_max > y:
				y_max = y
		if f3 == 0:
			if x_max > x:
				x_max = x
		if f4 == 0:
			if y_min < y:
				y_min = y
	if x_min <= x_max and y_min <= y_max:
		result.append(' '.join(('1', str(x_max), str(y_max))))
	else:
		result.append('0')
print('\n'.join(result))