You are given a non-degenerate triangle (a non-degenerate triangle is a triangle with positive area). The vertices of the triangle have coordinates $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$.

You want to draw a straight line to cut the triangle into two non-degenerate triangles. Furthermore, the line you draw should be either horizontal or vertical.

Can you draw the line to meet all the constraints?

Here are some suitable ways to draw the line:

However, these ways to draw the line are not suitable (the first line cuts the triangle into a triangle and a quadrangle; the second line doesn't cut the triangle at all; the third line is neither horizontal nor vertical):


-----Input-----

The first line contains one integer $t$ ($1 \le t \le 10^4$) — the number of test cases.

Each test case consists of four lines. The first of them is empty. The $i$-th of the next three lines contains two integers $x_i$ and $y_i$ ($1 \le x_i, y_i \le 10^8$) — the coordinates of the $i$-th vertex of the triangle.

Additional constraint on the input: in each test case, the triangle formed by three vertices has positive area (i. e. it is non-degenerate).


-----Output-----

For each test case, print YES if it is possible to cut the triangle according to the statement, or NO otherwise. You may print each letter in any case (YES, yes, Yes will all be recognized as positive answer, NO, no and nO will all be recognized as negative answer).


-----Examples-----

Input
4
4 7
6 8
3 5
4 5
4 7
6 8
5 8
1 8
2 5
3 6
6 6
6 3
Output
YES
YES
YES
NO


-----Note-----

None

Difficulty: EASY

Solutions:
import sys, math, cmath, time
from bisect import bisect_left
start_time = time.time()

def solve():
	s = input()
	l = []
	for i in range(3):
		(x, y) = map(int, input().split())
		l.append(x)
		l.append(y)
	if l[0] == l[2] or l[0] == l[4] or l[2] == l[4]:
		if l[3] == l[5] or l[1] == l[3] or l[5] == l[1]:
			print('NO')
			return
	print('YES')

def main():
	testcases = 1
	testcases = inp()
	for each_testcase in range(testcases):
		solve()

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

def inps():
	return input().split()
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
	input = sys.stdin.readline
main()


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	ele = input()
	xx = []
	yy = []
	for __ in 'XXX':
		(x, y) = input().split()
		xx.append(x)
		yy.append(y)
	print('NO' if len(set(xx)) < 3 and len(set(yy)) < 3 else 'YES')


import sys

def solve():
	inp = sys.stdin.readline
	inp()
	(x1, y1) = map(int, inp().split())
	(x2, y2) = map(int, inp().split())
	(x3, y3) = map(int, inp().split())
	xx = sorted([x1, x2, x3])
	yy = sorted([y1, y2, y3])
	if xx[1] > xx[0] and xx[1] < xx[2] or (yy[1] > yy[0] and yy[1] < yy[2]):
		print('YES')
	else:
		print('NO')

def main():
	for i in range(int(sys.stdin.readline())):
		solve()
main()


import sys
input = sys.stdin.readline
t = int(input())
(x, y) = ([0] * 3, [0] * 3)
for j in range(t):
	blank = input()
	for i in range(3):
		(x[i], y[i]) = map(int, input().split())
	x.sort()
	y.sort()
	if (x[0] == x[1] or x[1] == x[2]) and (y[0] == y[1] or y[1] == y[2]):
		print('NO')
	else:
		print('YES')


import sys
input = sys.stdin.readline

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

def readInt():
	return int(input())

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

def readStr():
	return input().strip()

def solve():
	(X, Y) = ([], [])
	input().strip()
	for i in range(3):
		(x, y) = readInts()
		if x not in X:
			X.append(x)
		if y not in Y:
			Y.append(y)
	if len(X) == 2 and len(Y) == 2:
		return 'NO'
	return 'YES'
for _ in range(int(input())):
	print(solve())


import sys
input = sys.stdin.readline
inp = sys.stdin.readline

def input():
	return inp().strip()

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

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

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

def solve():
	(x1, y1) = mi()
	(x2, y2) = mi()
	(x3, y3) = mi()
	if x1 != x2 and x2 != x3 and (x1 != x3):
		return 'YES'
	if y1 != y2 and y2 != y3 and (y1 != y3):
		return 'YES'
	return 'NO'

def main():
	for _ in range(ii()):
		input()
		print(solve())
main()


import math
from sys import stdin, stdout

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

def inlt():
	return list(map(int, stdin.readline().strip().split()))

def insr():
	s = stdin.readline().strip()
	return list(s[:len(s)])

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

def main():
	for i in range(inp()):
		stdin.readline()
		first = set()
		secod = set()
		for i in range(3):
			(a, b) = invr()
			first.add(a)
			secod.add(b)
		if len(first) == 3 or len(secod) == 3:
			print('YES')
		else:
			print('NO')
main()


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	useless = input()
	(X1, Y1) = list(map(int, input().split()))
	(X2, Y2) = list(map(int, input().split()))
	(X3, Y3) = list(map(int, input().split()))
	lst = [X1 - X2, Y1 - Y2, Y3 - Y2, X3 - X2, X1 - X3, Y1 - Y3]
	counter = 0
	for i in range(6):
		if lst[i] == 0:
			counter += 1
	if counter > 1:
		print('NO')
	else:
		print('YES')


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	e = sys.stdin.readline()
	(x1, y1) = sys.stdin.readline().split()
	(x1, y1) = (int(x1), int(y1))
	(x2, y2) = sys.stdin.readline().split()
	(x2, y2) = (int(x2), int(y2))
	(x3, y3) = sys.stdin.readline().split()
	(x3, y3) = (int(x3), int(y3))
	a = [(x1, y1), (x2, y2), (x3, y3)]
	a.sort()
	(x1, y1) = a[0]
	(x2, y2) = a[1]
	(x3, y3) = a[2]
	if x1 == x2:
		if y2 == y3 or y1 == y3:
			print('NO')
		else:
			print('YES')
	elif x2 == x3:
		if y1 == y2 or y1 == y3:
			print('NO')
		else:
			print('YES')
	else:
		print('YES')


import sys
lst = []
time = 0
for line in sys.stdin:
	if time == 0:
		n = int(line.split()[0])
		time = 1
		continue
	lst.append([int(x) for x in line.split()])
for i in range(n):
	set1 = {lst[4 * i + 1][0], lst[4 * i + 2][0], lst[4 * i + 3][0]}
	set2 = {lst[4 * i + 1][1], lst[4 * i + 2][1], lst[4 * i + 3][1]}
	if len(set1) == 3 or len(set2) == 3:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	input()
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	if a[0] == b[0]:
		if b[1] == c[1]:
			print('NO')
			continue
	if b[0] == c[0]:
		if c[1] == a[1]:
			print('NO')
			continue
	if c[0] == a[0]:
		if a[1] == b[1]:
			print('NO')
			continue
	if a[1] == b[1]:
		if b[0] == c[0]:
			print('NO')
			continue
	if b[1] == c[1]:
		if c[0] == a[0]:
			print('NO')
			continue
	if c[1] == a[1]:
		if a[0] == b[0]:
			print('NO')
			continue
	print('YES')


n = int(input())
output = []
for i in range(n):
	a = []
	b = []
	for j in range(4):
		arr = input()
		if arr != '':
			a.append(arr.split()[0])
			b.append(arr.split()[1])
	if a[0] == a[1]:
		if b[0] == b[2] or b[1] == b[2]:
			output.append('NO')
		else:
			output.append('YES')
	elif a[0] == a[2]:
		if b[0] == b[1] or b[1] == b[2]:
			output.append('NO')
		else:
			output.append('YES')
	elif a[1] == a[2]:
		if b[0] == b[1] or b[0] == b[2]:
			output.append('NO')
		else:
			output.append('YES')
	else:
		output.append('YES')
for i in output:
	print(i)


import sys
rd = sys.stdin.readline
for _ in range(int(rd())):
	rd()
	(x1, y1) = map(int, rd().split())
	(x2, y2) = map(int, rd().split())
	(x3, y3) = map(int, rd().split())
	if x1 == x2 and (y2 == y3 or y1 == y3):
		print('NO')
	elif x2 == x3 and (y2 == y1 or y3 == y1):
		print('NO')
	elif x1 == x3 and (y1 == y2 or y3 == y2):
		print('NO')
	else:
		print('YES')


import sys, math, heapq, bisect, random, itertools
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 5)
ints = lambda : list(map(int, input().split()))
p = 10 ** 9 + 7
inf = 10 ** 20 + 7
alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for t in range(int(input())):
	input()
	(x, y, z) = (ints(), ints(), ints())
	if x[0] == y[0] and x[1] == z[1]:
		print('NO')
	elif x[0] == z[0] and x[1] == y[1]:
		print('NO')
	elif y[0] == x[0] and y[1] == z[1]:
		print('NO')
	elif y[0] == z[0] and y[1] == x[1]:
		print('NO')
	elif z[0] == x[0] and z[1] == y[1]:
		print('NO')
	elif z[0] == y[0] and z[1] == x[1]:
		print('NO')
	else:
		print('YES')


T = int(input())
output = []
while T > 0:
	newline = input()
	(a1, a2) = map(int, input().split())
	(b1, b2) = map(int, input().split())
	(c1, c2) = map(int, input().split())
	y_equal = a2 == b2 or b2 == c2 or c2 == a2
	x_equal = a1 == b1 or b1 == c1 or c1 == a1
	if x_equal and y_equal:
		output.append('NO')
	else:
		output.append('YES')
	T -= 1
for x in output:
	print(x)


n = int(input())
R = []
for i in range(n):
	z = input()
	s1 = input().split()
	x = (int(s1[0]), int(s1[1]))
	s2 = input().split()
	y = (int(s2[0]), int(s2[1]))
	s3 = input().split()
	z = (int(s3[0]), int(s3[1]))
	R.append([x, y, z])

def main(x, y, z):
	if x[1] == y[1] and x[0] == z[0] or (x[1] == z[1] and x[0] == y[0]):
		return 'NO'
	if z[1] == y[1] and z[0] == x[0] or (z[1] == x[1] and z[0] == y[0]):
		return 'NO'
	if y[1] == x[1] and y[0] == z[0] or (y[1] == z[1] and y[0] == x[0]):
		return 'NO'
	return 'YES'
for i in R:
	print(main(i[0], i[1], i[2]))


u = int(input())
h11 = []
for rrrr in range(u):
	g = input()
	h1 = []
	h2 = []
	for ttttt in range(3):
		(g, h) = map(int, input().split())
		h1.append(g)
		h2.append(h)
	if h1.count(sorted(h1)[1]) == 1:
		h11.append('YES')
	elif h2.count(sorted(h2)[1]) == 1:
		h11.append('YES')
	else:
		h11.append('NO')
[print(h111) for h111 in h11]


import sys
input = sys.stdin.readline

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

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

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

def invr():
	return map(int, input().split())
test_cases = inp()
inp_arr = []
for i in range(test_cases):
	num = input()
	nums = inlt()
	(x1, y1) = (nums[0], nums[1])
	nums = inlt()
	(x2, y2) = (nums[0], nums[1])
	nums = inlt()
	(x3, y3) = (nums[0], nums[1])
	inp_arr.append([(x1, y1), (x2, y2), (x3, y3)])

def findResult(cors):
	(cor1, cor2, cor3) = cors
	(x1, y1) = cor1
	(x2, y2) = cor2
	(x3, y3) = cor3
	for (i, (x, y)) in enumerate(cors):
		((xo1, yo1), (xo2, yo2)) = cors[:i] + cors[i + 1:]
		if x == xo1 and y == yo2 or (x == xo2 and y == yo1):
			return 'NO'
	return 'YES'
result = [findResult(cheeses) for cheeses in inp_arr]
for m in result:
	print(m)


ans = []
for _ in range(int(input())):
	t = 'NO'
	input()
	c = [[int(i) for i in input().split()], [int(j) for j in input().split()], [int(k) for k in input().split()]]
	if (c[0][0] == c[1][0] or c[0][0] == c[2][0] or c[1][0] == c[2][0]) and (c[0][1] == c[1][1] or c[0][1] == c[2][1] or c[1][1] == c[2][1]):
		ans.append('NO')
	else:
		ans.append('YES')
print(*ans, sep='\n')


import sys
input = sys.stdin.readline

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

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

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

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

def output_list(l):
	print(' '.join(list(map(str, l))))

class Node:

	def __init__(self, i, next):
		self.i = i
		self.next = next

	def __str__(self):
		return str(self.i)

def test_case():
	input()
	(x_1, y_1) = inlt()
	(x_2, y_2) = inlt()
	(x_3, y_3) = inlt()
	x = [x_1, x_2, x_3]
	y = [y_1, y_2, y_3]
	if len(set(x)) == 3 or len(set(y)) == 3:
		print('YES')
	else:
		print('NO')
n_cases = inp()
for i in range(n_cases):
	test_case()


from collections import defaultdict
from sys import stdin, stdout
import math
import string

def solution(N):
	return math.ceil(N / 2)
test_cases = int(stdin.readline())
for it in range(test_cases):
	a = stdin.readline()
	pairs = []
	xs = set()
	ys = set()
	for n in range(3):
		(x, y) = map(int, tuple(stdin.readline().split()))
		pairs.append((x, y))
		xs.add(x)
		ys.add(y)
	if len(xs) < 3 and len(ys) < 3:
		print('NO')
	else:
		print('YES')


import sys
import math
from bisect import bisect_right as br
from collections import deque, Counter
from itertools import combinations as cb
from collections import deque

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

def str_arr():
	return list(map(str, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	p = input()
	a = []
	b = []
	for i in range(3):
		x = int_arr()
		a.append(x[0])
		b.append(x[1])
	a.sort()
	b.sort()
	if a[0] < a[1] and a[1] < a[2]:
		print('YES')
	elif b[0] < b[1] and b[1] < b[2]:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	x = input()
	(a1, b1) = input().split()
	(a2, b2) = input().split()
	(a3, b3) = input().split()
	if a1 == a2 and (b1 == b3 or b2 == b3):
		print('NO')
	elif a1 == a3 and (b1 == b2 or b3 == b2):
		print('NO')
	elif a3 == a2 and (b3 == b1 or b2 == b1):
		print('NO')
	elif b1 == b2 and (a1 == a3 or a2 == a3):
		print('NO')
	elif b1 == b3 and (a1 == a2 or a3 == a2):
		print('NO')
	elif b3 == b2 and (a3 == a1 or a2 == a1):
		print('NO')
	else:
		print('YES')


l = []
for i in range(int(input())):
	input()
	x = []
	y = []
	(x1, y1) = map(int, input().split())
	x.append(x1)
	y.append(y1)
	(x2, y2) = map(int, input().split())
	x.append(x2)
	y.append(y2)
	(x3, y3) = map(int, input().split())
	x.append(x3)
	y.append(y3)
	if len(set(x)) != len(x) and len(set(y)) != len(y):
		l.append('NO')
	else:
		l.append('YES')
for h in l:
	print(h)


t = int(input())
res = []
for i in range(t):
	tr = []
	a = input()
	for j in range(3):
		points = list(map(int, input().split()))
		tr.append(points[0])
		tr.append(points[1])
	if len(set(tr)) <= len(tr) - 2:
		if tr[0] == tr[4] and tr[1] == tr[3] or (tr[0] == tr[2] and tr[1] == tr[5]) or (tr[1] == tr[3] and tr[2] == tr[4]) or (tr[1] == tr[5] and tr[2] == tr[4]) or (tr[0] == tr[4] and tr[3] == tr[5]) or (tr[3] == tr[5] and tr[0] == tr[2]):
			res.append('NO')
		else:
			res.append('YES')
	else:
		res.append('YES')
for i in res:
	print(i)


def fun(L):
	x = []
	y = []
	for l in L:
		x.append(l[0])
		y.append(l[1])
	nx = len(set(x))
	ny = len(set(y))
	if nx == 2 and ny == 2:
		return 'NO'
	else:
		return 'YES'
t = int(input())
ans = []
for i in range(t):
	L = []
	for j in range(4):
		if j != 0:
			s = str(input()).split()
			L.append(s)
		else:
			s0 = input()
	ans.append(fun(L))
for i in range(t):
	print(ans[i])


t = int(input())
loo = []
for i in range(t):
	e = input()
	p1 = input().split()
	for j in range(2):
		p1[j] = int(p1[j])
	p2 = input().split()
	for j in range(2):
		p2[j] = int(p2[j])
	p3 = input().split()
	for j in range(2):
		p3[j] = int(p3[j])
	x = [p1[0], p2[0], p3[0]]
	x.sort()
	y = [p1[1], p2[1], p3[1]]
	y.sort()
	if x[0] < x[1] and x[1] < x[2] or (y[0] < y[1] and y[1] < y[2]):
		loo.append('YES')
	else:
		loo.append('NO')
for i in range(t):
	print(loo[i])


t = int(input())
result = []
for i in range(t):
	h = input()
	(x1, y1) = list(map(int, input().split(' ')))
	(x2, y2) = list(map(int, input().split(' ')))
	(x3, y3) = list(map(int, input().split(' ')))
	x = [x1, x2, x3]
	y = [y1, y2, y3]
	x.sort()
	y.sort()
	if (x[0] < x[1] < x[2]) | (y[0] < y[1] < y[2]):
		result.append('YES')
	else:
		result.append('NO')
for i in result:
	print(i)


def f():
	n = input()
	l1 = input().split(' ')
	l2 = input().split(' ')
	l3 = input().split(' ')
	x1 = l1[0]
	y1 = l1[1]
	x2 = l2[0]
	y2 = l2[1]
	x3 = l3[0]
	y3 = l3[1]
	a = 0
	b = 0
	if x1 == x2:
		a += 2
	if x1 == x3:
		a += 2
	if x2 == x3:
		a += 2
	if y1 == y2:
		b += 2
	if y1 == y3:
		b += 2
	if y2 == y3:
		b += 2
	if a == 2 and b == 2:
		print('NO')
		return 0
	else:
		print('YES')
		return 0
r = int(input())
for i in range(r):
	f()


n = input()
n = int(n)
for i in range(n):
	f = input()
	(x, y) = map(int, input().split())
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	if y1 == y2 and x1 == x:
		print('NO')
	elif y == y1 and x1 == x2:
		print('NO')
	elif x == x2 and y1 == y2:
		print('NO')
	elif y == y2 and x1 == x2:
		print('NO')
	elif x == x1 and y == y2:
		print('NO')
	elif x == x2 and y == y1:
		print('NO')
	else:
		print('YES')


number_of_tc = int(input())
for tc in range(number_of_tc):
	empty_input = input()
	triangle_1 = input().split()
	triangle_2 = input().split()
	triangle_3 = input().split()
	if triangle_1[0] != triangle_2[0] and triangle_1[0] != triangle_3[0] and (triangle_2[0] != triangle_3[0]):
		print('YES')
	elif triangle_1[1] != triangle_2[1] and triangle_1[1] != triangle_3[1] and (triangle_2[1] != triangle_3[1]):
		print('YES')
	else:
		print('NO')


def inpi():
	return int(input())

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

def inps():
	s = input()
	return list(s[:len(s)])

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

def inpst():
	return set(map(int, input().split()))

def solve():
	input()
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	if (x1 == x2 or x1 == x3 or x2 == x3) and (y1 == y2 or y1 == y3 or y2 == y3):
		print('NO')
	else:
		print('YES')
t = inpi()
for _ in range(t):
	solve()


t = int(input())
for i in range(t):
	z = input()
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	ans = 'YES'
	if x1 == x2 and y1 == y3:
		ans = 'NO'
	if x1 == x3 and y1 == y2:
		ans = 'NO'
	if x2 == x3 and y2 == y1:
		ans = 'NO'
	if x2 == x1 and y2 == y3:
		ans = 'NO'
	if x3 == x1 and y3 == y2:
		ans = 'NO'
	if x3 == x2 and y3 == y1:
		ans = 'NO'
	print(ans)


tn = int(input())
for _ in range(tn):
	input()
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	if (a[0] == b[0] or a[0] == c[0] or b[0] == c[0]) and (a[1] == b[1] or a[1] == c[1] or b[1] == c[1]):
		print('NO')
	else:
		print('YES')


for i in range(int(input())):
	empty = input()
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	flag = 1
	if x1 == x2:
		if y2 == y3 or y3 == y1:
			flag = 0
	elif x2 == x3:
		if y3 == y1 or y2 == y1:
			flag = 0
	elif x3 == x1:
		if y2 == y1 or y2 == y3:
			flag = 0
	if flag:
		print('YES')
	else:
		print('NO')


t = input()
for i in range(0, int(t)):
	x = input()
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	if (x1 == x2 or x2 == x3 or x1 == x3) and (y1 == y2 or y2 == y3 or y1 == y3):
		print('NO')
	else:
		print('YES')


t = int(input())
for tc in range(t):
	l = input()
	(x1, y1) = map(int, input().split(' '))
	(x2, y2) = map(int, input().split(' '))
	(x3, y3) = map(int, input().split(' '))
	x = [x1, x2, x3]
	y = [y1, y2, y3]
	if (x1 == x2 or x1 == x3 or x2 == x3) and (y1 == y2 or y1 == y3 or y2 == y3):
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(0, t):
	s = input()
	(x1, y1) = input().split()
	(x2, y2) = input().split()
	(x3, y3) = input().split()
	if x1 == x2 and y1 == y3 or (x2 == x3 and y2 == y1) or (x3 == x1 and y3 == y2) or (x2 == x1 and y2 == y3) or (x3 == x2 and y3 == y1) or (x1 == x3 and y1 == y2):
		print('NO')
	else:
		print('YES')


a = int(input())
for i in range(a):
	b = input()
	(x1, y1) = input().split()
	(x2, y2) = input().split()
	(x3, y3) = input().split()
	if x1 == x2:
		if y2 == y3 or y1 == y3:
			print('NO')
			continue
	elif x2 == x3:
		if y3 == y1 or y2 == y1:
			print('NO')
			continue
	elif x1 == x3:
		if y3 == y2 or y1 == y2:
			print('NO')
			continue
	elif y1 == y2:
		if x2 == x3 or x1 == x3:
			print('NO')
			continue
	elif y2 == y3:
		if x3 == x1 or x2 == x1:
			print('NO')
			continue
	elif y1 == y3:
		if x3 == x2 or x1 == x2:
			print('NO')
			continue
	print('YES')


inputs = []
for i in range(int(input())):
	_ = input()
	coordinates = []
	for _ in range(3):
		input_str = input()
		input_str = list(map(int, input_str.split(' ')))
		coordinates.append(input_str)
	inputs.append(coordinates)
for coords in inputs:
	ishorz = (coords[0][0] == coords[1][0]) | (coords[1][0] == coords[2][0]) | (coords[0][0] == coords[2][0])
	isvert = (coords[0][1] == coords[1][1]) | (coords[1][1] == coords[2][1]) | (coords[0][1] == coords[2][1])
	print('NO' if isvert & ishorz else 'YES')


for i in range(int(input())):
	(a, b, c, d) = (input(), input().split(), input().split(), input().split())
	(x, y) = ([b[0], c[0], d[0]], [b[1], c[1], d[1]])
	(x1, y1) = ([], [])
	for i in x:
		if i not in x1:
			x1 += [i]
	for i in y:
		if i not in y1:
			y1 += [i]
	if len(x1) == 2 and len(y1) == 2:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	s = input()
	(ax, ay) = map(int, input().split())
	(bx, by) = map(int, input().split())
	(cx, cy) = map(int, input().split())
	if (ax == bx or cx == bx or ax == cx) and (ay == by or ay == cy or by == cy):
		print('NO')
	else:
		print('YES')


for i in range(int(input())):
	x0 = input()
	(x1, y1) = map(int, input().split(' '))
	(x2, y2) = map(int, input().split(' '))
	(x3, y3) = map(int, input().split(' '))
	if (x1 == x2 or x1 == x3 or x2 == x3) and (y1 == y2 or y1 == y3 or y2 == y3):
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	s = input()
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	xx = {x1, x2, x3}
	yy = {y1, y2, y3}
	if len(xx) == len(yy):
		if len(xx) == 2:
			print('NO')
		else:
			print('YES')
	else:
		print('YES')


for t in range(int(input())):
	empty = input()
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	if (x1 == x2 or x2 == x3 or x1 == x3) and (y1 == y2 or y2 == y3 or y1 == y3):
		print('NO')
	else:
		print('YES')


try:
	for _ in range(int(input())):
		input()
		(x1, y1) = map(int, input().split())
		(x2, y2) = map(int, input().split())
		(x3, y3) = map(int, input().split())
		flag = False
		if x1 != x2 and x2 != x3 and (x1 != x3):
			flag = 1
		if y1 != y2 and y2 != y3 and (y1 != y3):
			flag = 1
		if flag:
			print('YES')
		else:
			print('NO')
except Exception as e:
	print(e)


for _ in range(int(input())):
	c = input()
	(x, y) = map(int, input().split())
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	if x == x1 and y == y2:
		print('NO')
	elif x == x2 and y == y1:
		print('NO')
	elif x == x1 and y1 == y2:
		print('NO')
	elif x2 == x1 and y1 == y:
		print('NO')
	elif x == x2 and y2 == y1:
		print('NO')
	elif x1 == x2 and y2 == y:
		print('NO')
	else:
		print('YES')


import math
case = int(input())
for _ in range(case):
	input()
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	if (abs(x1) == abs(x2) or abs(x1) == abs(x3) or abs(x2) == abs(x3)) and (abs(y1) == abs(y2) or abs(y1) == abs(y3) or abs(y2) == abs(y3)):
		print('NO')
	else:
		print('YES')


for i in range(int(input())):
	input()
	(x, y) = map(int, input().split())
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	if y == y1 and x == x1 or (y == y1 and x == x2) or (y == y1 and x1 == x2) or (y == y2 and x == x1) or (y == y2 and x == x2) or (y == y2 and x1 == x2) or (y1 == y2 and x == x1) or (y1 == y2 and x == x2) or (y1 == y2 and x1 == x2):
		print('NO')
	else:
		print('YES')


tests = int(input())
for i in range(tests):
	_ = input()
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	if len(set([x1, x2, x3])) == len(set([y1, y2, y3])) == 2:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	em = input()
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	ans = 'NO'
	if x1 > x2 and x1 < x3 or (x1 > x3 and x1 < x2):
		ans = 'YES'
	elif x2 > x1 and x2 < x3 or (x2 > x3 and x2 < x1):
		ans = 'YES'
	elif x3 > x1 and x3 < x2 or (x3 > x2 and x3 < x1):
		ans = 'YES'
	elif y1 > y2 and y1 < y3 or (y1 > y3 and y1 < y2):
		ans = 'YES'
	elif y2 > y1 and y2 < y3 or (y2 > y3 and y2 < y1):
		ans = 'YES'
	elif y3 > y1 and y3 < y2 or (y3 > y2 and y3 < y1):
		ans = 'YES'
	print(ans)


for _ in range(int(input())):
	ch = input()
	c1 = [int(x) for x in input().split()]
	c2 = [int(x) for x in input().split()]
	c3 = [int(x) for x in input().split()]
	if (c1[0] == c2[0] or c1[0] == c3[0] or c3[0] == c2[0]) and (c1[1] == c2[1] or c2[1] == c3[1] or c1[1] == c3[1]):
		print('NO')
	else:
		print('YES')


def isVert(x1, y1, x2, y2, x3, y3):
	return x1 != x2 and x1 != x3 and (x2 != x3)

def isHor(x1, y1, x2, y2, x3, y3):
	return y1 not in [y2, y3] and y2 != y3

def slope(x1, y1, x2, y2):
	return y2 - y1 == -1 * (x2 - x1)
t = int(input())
for t0 in range(t):
	x = input()
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	if isVert(x1, y1, x2, y2, x3, y3) or isHor(x1, y1, x2, y2, x3, y3):
		print('YES')
	else:
		print('NO')


t = int(input())
for j in range(t):
	m = map(int, input().split())
	(x1, y1) = list(map(int, input().split()))
	(x2, y2) = list(map(int, input().split()))
	(x3, y3) = list(map(int, input().split()))
	if x1 > x2 and x1 < x3 or (x1 > x3 and x1 < x2) or (x2 > x1 and x2 < x3) or (x2 > x3 and x2 < x1) or (x1 < x3 and x3 < x2) or (x1 > x3 and x2 < x3) or (y1 > y2 and y1 < y3) or (y1 > y3 and y1 < y2) or (y2 > y1 and y2 < y3) or (y2 > y3 and y2 < y1) or (y1 < y3 and y3 < y2) or (y1 > y3 and y2 < y3):
		print('YES')
	else:
		print('NO')


t = int(input(''))
while t:
	x = input('')
	(a, b) = map(int, input().split())
	(c, d) = map(int, input().split())
	(e, f) = map(int, input().split())
	if (a > c and a < e or (a < c and a > e)) or (c > a and c < e or (c < a and c > e)) or (e < a and e > c or (e > a and e < c)):
		print('YES')
	elif (b > d and b < f or (b < d and b > f)) or (d > b and d < f or (d < b and d > f)) or (f < b and f > d or (f > b and f < d)):
		print('YES')
	else:
		print('NO')
	t -= 1


for _ in range(int(input())):
	t = input()
	(x1, y1) = list(map(int, input().split()))
	(x2, y2) = list(map(int, input().split()))
	(x3, y3) = list(map(int, input().split()))
	if x1 == x2 and y3 in [y2, y1]:
		print('NO')
		continue
	elif x2 == x3 and y1 in [y2, y3]:
		print('NO')
		continue
	elif x3 == x1 and y2 in [y3, y1]:
		print('NO')
		continue
	print('YES')


def solve(points):
	ans = 'YES'
	match_count = 0
	for i in range(len(points) - 1):
		point1 = points[i]
		for j in range(i + 1, len(points)):
			point2 = points[j]
			if point1[0] == point2[0] or point1[1] == point2[1]:
				match_count += 1
	if match_count >= 2:
		ans = 'NO'
	print(ans)
	return
case_count = int(input())
cases = []
for i in range(case_count):
	points = []
	input()
	for j in range(3):
		point = input().split(' ')
		point_list = []
		for k in range(len(point)):
			point_list.append(int(point[k]))
		points.append(point_list)
	cases.append(points)
for case in cases:
	solve(case)


for i in range(int(input())):
	l = []
	s = input()
	(p1, q1) = map(int, input().split())
	(p2, q2) = map(int, input().split())
	(p3, q3) = map(int, input().split())
	if (p1 == p2 or p1 == p3 or p2 == p3) and (q1 == q2 or q2 == q3 or q1 == q3):
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	s = input()
	(a, b) = map(int, input().split())
	(c, d) = map(int, input().split())
	(e, f) = map(int, input().split())
	(x, y) = ([a, c, e], [b, d, f])
	if len(set(x)) < 3 and len(set(y)) < 3:
		print('NO')
	else:
		print('YES')


from math import sqrt

def getDist(x1, y1, x2, y2):
	return (x1 - x2) ** 2 + (y1 - y2) ** 2
t = int(input())
for _ in range(t):
	input()
	(x1, y1) = [int(i) for i in input().split()]
	(x2, y2) = [int(i) for i in input().split()]
	(x3, y3) = [int(i) for i in input().split()]
	x = {x1, x2, x3}
	y = {y1, y2, y3}
	if len(x) != 3 and len(y) != 3:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	bin = input()
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	ans = 0
	if (x2 - x1) * (x3 - x1) < 0:
		ans += 1
	if (y2 - y1) * (y3 - y1) < 0:
		ans += 1
	if (x3 - x2) * (x1 - x2) < 0:
		ans += 1
	if (y3 - y2) * (y1 - y2) < 0:
		ans += 1
	if (x1 - x3) * (x2 - x3) < 0:
		ans += 1
	if (y1 - y3) * (y2 - y3) < 0:
		ans += 1
	if ans > 0:
		print('YES')
	else:
		print('NO')


def ist(x1, y1, x2, y2, x3, y3):
	if x1 == x2 and (y1 == y3 or y2 == y3) or (x2 == x3 and (y2 == y1 or y1 == y3)) or (x3 == x1 and (y3 == y2 or y1 == y2)) or (x1 == x2 and (y1 == y3 or y2 == y3)):
		return 'No'
	else:
		return 'Yes'
n = int(input())
while n > 0:
	void = input()
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	res = ist(x1, y1, x2, y2, x3, y3)
	n = n - 1
	if res == 'No':
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	n = input()
	(x1, y1) = list(map(int, input().split()))
	(x2, y2) = list(map(int, input().split()))
	(x3, y3) = list(map(int, input().split()))
	if x1 == x2 or x1 == x3 or x2 == x3:
		if y1 == y2 or y1 == y3 or y2 == y3:
			print('NO')
		else:
			print('YES')
	else:
		print('YES')


I = input
for _ in [0] * int(I()):
	I()
	print('YNEOS'[max(map(len, map(set, zip(*(I().split() for _ in '***'))))) < 3::2])


t = int(input())
for i in range(0, t):
	k = input()
	a = [int(b) for b in input().split()]
	b = [int(b) for b in input().split()]
	c = [int(b) for b in input().split()]
	if (a[0] == b[0] or a[0] == c[0] or b[0] == c[0]) and (a[1] == b[1] or a[1] == c[1] or b[1] == c[1]):
		print('NO')
	else:
		print('YES')


n = int(input())
for i in range(n):
	empty1 = input()
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	if (x2 < x1 < x3 or x3 < x1 < x2) or (y2 < y1 < y3 or y3 < y1 < y2):
		print('YES')
	elif (x1 < x2 < x3 or x3 < x2 < x1) or (y1 < y2 < y3 or y3 < y2 < y1):
		print('YES')
	elif (x1 < x3 < x2 or x2 < x3 < x1) or (y2 < y3 < y1 or y1 < y3 < y2):
		print('YES')
	else:
		print('NO')


t = int(input())
for pushups in range(t):
	a = input()
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	if x1 == x2 or x2 == x3 or x3 == x1:
		if y1 == y2 or y2 == y3 or y3 == y1:
			print('NO')
		else:
			print('YES')
	else:
		print('YES')


import math
from collections import *

def solve():
	n = input()
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	c = 0
	if x1 == x2 or x2 == x3 or x1 == x3:
		c += 1
	if y1 == y2 or y2 == y3 or y3 == y1:
		c += 1
	if c > 1:
		print('NO')
	else:
		print('YES')
t = int(input())
for _ in range(t):
	solve()


def func(x1, y1, x2, y2, x3, y3):
	if (x1 == x2 or x2 == x3 or x1 == x3) and (y1 == y2 or y1 == y3 or y2 == y3):
		return 'NO'
	return 'YES'

def main():
	t = int(input())
	for i in range(t):
		input()
		(x1, y1) = map(int, input().split())
		(x2, y2) = map(int, input().split())
		(x3, y3) = map(int, input().split())
		print(func(x1, y1, x2, y2, x3, y3))
main()


n = int(input())
for i in range(n):
	input()
	(x, y) = map(int, input().split(' '))
	(a, b) = map(int, input().split(' '))
	(c, z) = map(int, input().split(' '))
	ans = 0
	ans += x == a or y == b
	ans += a == c or b == z
	ans += x == c or y == z
	if ans < 2:
		print('YES')
	else:
		print('NO')