Watson gives four 3-dimensional points to Sherlock and asks him if they all lie in the same plane. Your task here is to help Sherlock.   

Input Format 

First line contains T, the number of testcases. 

Each test case consists of four lines. Each line contains three integers, denoting x_{i} y_{i} z_{i}.   

Output Format 

For each test case, print YES or NO whether all four points lie in same plane or not, respectively.  

Constraints 

1 ≤ T ≤ 10^{4} 

-10^{3} ≤ x_{i},y_{i},z_{i} ≤ 10^{3}  

Sample Input

1
1 2 0
2 3 0
4 0 0
0 0 0

Sample Output

YES

Explanation 

All points have z_{i} = 0, hence they lie in the same plane, and output is YES

Source: hackerrank | Difficulty: EASY
Tags: Geometry


Solutions:
import sys
T = int(sys.stdin.readline())
for _ in range(T):
	A = list(map(int, sys.stdin.readline().split()))
	B = list(map(int, sys.stdin.readline().split()))
	C = list(map(int, sys.stdin.readline().split()))
	D = list(map(int, sys.stdin.readline().split()))
	AB = [x - y for (x, y) in zip(B, A)]
	AC = [x - y for (x, y) in zip(C, A)]
	AD = [x - y for (x, y) in zip(D, A)]
	V = AB[0] * (AC[1] * AD[2] - AC[2] * AD[1])
	V += AB[1] * (AC[0] * AD[2] - AC[2] * AD[0])
	V += AB[2] * (AC[0] * AD[1] - AC[1] * AD[0])
	print('YES' if V == 0 else 'NO')


t = int(input())

def read_point():
	return tuple((int(s) for s in input().split()))

def vec(a, b):
	return tuple((x1 - x0 for (x0, x1) in zip(a, b)))

def det(m):
	return m[0][0] * m[1][1] * m[2][2] + m[0][1] * m[1][2] * m[2][0] + m[0][2] * m[1][0] * m[2][1] - m[0][2] * m[1][1] * m[2][0] - m[0][1] * m[1][0] * m[2][2] - m[0][0] * m[1][2] * m[2][1]
for _ in range(t):
	(a, b, c, d) = (read_point() for _ in range(4))
	vs = tuple((vec(a, x) for x in (b, c, d)))
	print('YES' if det(vs) == 0 else 'NO')


def determinant_3x3(m):
	return m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1]) - m[1][0] * (m[0][1] * m[2][2] - m[0][2] * m[2][1]) + m[2][0] * (m[0][1] * m[1][2] - m[0][2] * m[1][1])

def subtract(a, b):
	return (a[0] - b[0], a[1] - b[1], a[2] - b[2])
ntest = int(input())
for i in range(ntest):
	a = list(map(float, input().split(' ')))
	b = list(map(float, input().split(' ')))
	c = list(map(float, input().split(' ')))
	d = list(map(float, input().split(' ')))
	if abs(determinant_3x3((subtract(a, b), subtract(b, c), subtract(c, d)))) / 6.0 == 0:
		print('YES')
	else:
		print('NO')


def cross(a, b):
	c = [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]]
	return c

def dot(a, b):
	return sum((i * j for (i, j) in zip(a, b)))

def case(p, q, r, s):
	pq = [q[0] - p[0], q[1] - p[1], q[2] - p[2]]
	pr = [r[0] - p[0], r[1] - p[1], r[2] - p[2]]
	ps = [s[0] - p[0], s[1] - p[1], s[2] - p[2]]
	if dot(ps, cross(pr, pq)) == 0:
		return 'YES'
	else:
		return 'NO'
t = int(input())
for i in range(t):
	p = list(map(int, input().split()))
	q = list(map(int, input().split()))
	r = list(map(int, input().split()))
	s = list(map(int, input().split()))
	print(case(p, q, r, s))


from sys import stdin as cin
from math import factorial as f
for t in range(int(cin.readline())):
	a = list(map(int, cin.readline().split()))
	b = list(map(int, cin.readline().split()))
	c = list(map(int, cin.readline().split()))
	d = list(map(int, cin.readline().split()))
	x1 = a[0] - b[0]
	x2 = a[1] - b[1]
	x3 = a[2] - b[2]
	y1 = c[0] - a[0]
	y2 = c[1] - a[1]
	y3 = c[2] - a[2]
	z1 = d[0] - a[0]
	z2 = d[1] - a[1]
	z3 = d[2] - a[2]
	m = z1 * (x2 * y3 - x3 * y2) + z2 * (x3 * y1 - x1 * y3) + z3 * (x1 * y2 - x2 * y1)
	if m == 0:
		print('YES')
	else:
		print('NO')


from math import *
tc = int(input())
i = 0
while i < tc:
	(a1, b1, c1) = map(int, input().split())
	(a2, b2, c2) = map(int, input().split())
	(a3, b3, c3) = map(int, input().split())
	(a4, b4, c4) = map(int, input().split())
	vec12 = [a2 - a1, b2 - b1, c2 - c1]
	vec13 = [a3 - a1, b3 - b1, c3 - c1]
	vec14 = [a4 - a1, b4 - b1, c4 - c1]
	det = vec12[0] * vec13[1] * vec14[2] + vec12[1] * vec13[2] * vec14[0] + vec12[2] * vec13[0] * vec14[1] - (vec12[2] * vec13[1] * vec14[0] + vec12[1] * vec13[0] * vec14[2] + vec12[0] * vec13[2] * vec14[1])
	if det == 0:
		print('YES')
	else:
		print('NO')
	i += 1


t = int(input())
a = [None] * 4
b = [None] * 4
c = [None] * 4
e = [None] * 3
f = [None] * 3
g = [None] * 3
for j in range(t):
	for i in range(4):
		(a[i], b[i], c[i]) = map(int, input().split())
	for i in range(3):
		e[i] = a[i + 1] - a[i]
		f[i] = b[i + 1] - b[i]
		g[i] = c[i + 1] - c[i]
	t = e[0] * (f[1] * g[2] - g[1] * f[2]) - f[0] * (e[1] * g[2] - e[2] * g[1]) + g[0] * (e[1] * f[2] - e[2] * f[1])
	if t == 0:
		print('YES')
	else:
		print('NO')


def main():
	for i in range(int(input())):
		c1 = input().split()
		c2 = input().split()
		c3 = input().split()
		c4 = input().split()
		x1 = int(c1[0])
		y1 = int(c1[1])
		z1 = int(c1[2])
		x2 = int(c2[0])
		y2 = int(c2[1])
		z2 = int(c2[2])
		x3 = int(c3[0])
		y3 = int(c3[1])
		z3 = int(c3[2])
		x4 = int(c4[0])
		y4 = int(c4[1])
		z4 = int(c4[2])
		print('YES') if x1 == x2 == x3 == x4 or y1 == y2 == y3 == y4 or z1 == z2 == z3 == z4 else print('NO')
main()


import math

def crp(a, b):
	l = []
	l.append(a[1] * b[2] - a[2] * b[1])
	l.append(a[2] * b[0] - a[0] * b[2])
	l.append(a[0] * b[1] - a[1] * b[0])
	return l

def sub(a, b):
	l = []
	for i in range(3):
		l.append(a[i] - b[i])
	return l
t = int(input())
for tst in range(t):
	vecs = []
	for j in range(4):
		s = input().strip().split()
		r = []
		for vl in s:
			r.append(eval(vl))
		vecs.append(r)
	p = vecs[0]
	q = vecs[1]
	x = vecs[2]
	y = vecs[3]
	n = crp(sub(p, q), sub(x, q))
	if n[0] * (y[0] - q[0]) + n[1] * (y[1] - q[1]) + n[2] * (y[2] - q[2]) == 0:
		print('YES')
	else:
		print('NO')


import sys
T = int(sys.stdin.readline())
for _ in range(T):
	A = list(map(int, sys.stdin.readline().split()))
	B = list(map(int, sys.stdin.readline().split()))
	C = list(map(int, sys.stdin.readline().split()))
	D = list(map(int, sys.stdin.readline().split()))
	AB = [x - y for (x, y) in zip(B, A)]
	AC = [x - y for (x, y) in zip(C, A)]
	AD = [x - y for (x, y) in zip(D, A)]
	V = AB[0] * (AC[1] * AD[2] - AC[2] * AD[1])
	V += AB[1] * (AC[0] * AD[2] - AC[2] * AD[0])
	V += AB[2] * (AC[0] * AD[1] - AC[1] * AD[0])
	print('YES' if V == 0 else 'NO')


for i in range(int(input().rstrip())):
	ps = [[int(e) for e in input().rstrip().split()] for _ in range(4)]
	if ps[0][0] == 0:
		for (j, p) in enumerate(ps):
			if p[0] != 0:
				(ps[0], ps[j]) = (p, ps[0])
				break
		else:
			print('YES')
			continue
	p0 = ps[0]
	for p in ps[1:]:
		f = p[0] / p0[0]
		for c in range(3):
			p[c] -= p0[c] * f
		p.append(1 - f)
	d = ps[1][1] * ps[2][2] * ps[3][3] + ps[1][2] * ps[2][3] * ps[3][1] + ps[2][1] * ps[3][2] * ps[1][3] - ps[1][3] * ps[2][2] * ps[3][1] - ps[3][2] * ps[1][1] * ps[2][3] - ps[2][1] * ps[1][2] * ps[3][3]
	if abs(d) < 1e-15:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	p1 = input().split()
	p2 = input().split()
	p3 = input().split()
	p4 = input().split()
	n = None
	for i in range(3):
		if p1[i] == p2[i] and p2[i] == p3[i] and (p3[i] == p4[i]):
			print('YES')
			n = 0
			break
	if n == None:
		print('NO')


def insameplane(a, b, c, d):
	ab = [b[0] - a[0], b[1] - a[1], b[2] - a[2]]
	ac = [c[0] - a[0], c[1] - a[1], c[2] - a[2]]
	ad = [d[0] - a[0], d[1] - a[1], d[2] - a[2]]
	abXac = [ab[1] * ac[2] - ab[2] * ac[1], -ab[0] * ac[2] + ab[2] * ac[0], ab[0] * ac[1] - ab[1] * ac[0]]
	return abs(abXac[0] * ad[0] + abXac[1] * ad[1] + abXac[1] * ad[1]) < 1e-08

def solve():
	N = int(input())
	i = 0
	while i < N:
		k = 0
		textA = input()
		textA = textA.split()
		textB = input()
		textB = textB.split()
		textC = input()
		textC = textC.split()
		textD = input()
		textD = textD.split()
		a = []
		b = []
		c = []
		d = []
		while k < 3:
			a.append(int(textA[k]))
			b.append(int(textB[k]))
			c.append(int(textC[k]))
			d.append(int(textD[k]))
			k += 1
		res = insameplane(a, b, c, d)
		if res == True:
			print('YES')
		else:
			print('NO')
		i += 1
solve()


def inputArray():
	point = list(map(int, input().split()))
	return point

def checkPlane(p1, p2, p3, p4):
	x1 = p1[0]
	x2 = p2[0]
	x3 = p3[0]
	y1 = p1[1]
	y2 = p2[1]
	y3 = p3[1]
	z1 = p1[2]
	z2 = p2[2]
	z3 = p3[2]
	a = y1 * z2 - y1 * z3 - y2 * z1 + y2 * z3 + y3 * z1 - y3 * z2
	b = -1 * x1 * z2 + x1 * z3 + x2 * z1 - x2 * z3 - x3 * z1 + x3 * z2
	c = x1 * y2 - x1 * y3 - x2 * y1 + x2 * y3 + x3 * y1 - x3 * y2
	d = -1 * x1 * y2 * z3 + x1 * y3 * z2 + x2 * y1 * z3 - x2 * y3 * z1 - x3 * y1 * z2 + x3 * y2 * z1
	r = a * p4[0] + b * p4[1] + c * p4[2] + d
	if r == 0:
		print('YES')
	else:
		print('NO')
T = int(input())
for a in range(1, T + 1):
	p1 = inputArray()
	p2 = inputArray()
	p3 = inputArray()
	p4 = inputArray()
	checkPlane(p1, p2, p3, p4)


def isSamePoint(p1, p2):
	if p1[0] == p2[0] and p1[1] == p2[1] and (p1[2] == p2[2]):
		return True
	return False
T = int(input())
for i in range(0, T):
	p1 = [int(x) for x in input().split()]
	p2 = [int(x) for x in input().split()]
	p3 = [int(x) for x in input().split()]
	p4 = [int(x) for x in input().split()]
	if isSamePoint(p1, p2):
		print('YES')
		continue
	if isSamePoint(p1, p3):
		print('YES')
		continue
	if isSamePoint(p1, p4):
		print('YES')
		continue
	a = [p1[i] - p2[i] for i in range(0, 3)]
	b = [p1[i] - p3[i] for i in range(0, 3)]
	c = [p1[i] - p4[i] for i in range(0, 3)]
	x = b[1] * a[2] - a[1] * b[2]
	y = a[0] * b[2] - b[0] * a[2]
	z = b[0] * a[1] - a[0] * b[1]
	s = x * c[0] + y * c[1] + z * c[2]
	if s == 0:
		print('YES')
	else:
		print('NO')


class Point:

	def __init__(self, x, y, z):
		self.x = x
		self.y = y
		self.z = z

	def cross(self, other):
		return Point(self.y * other.z - self.z * other.y, self.z * other.x - self.x * other.z, self.x * other.y - self.y * other.x)

	def dot(self, other):
		return self.x * other.x + self.y * other.y + self.z * other.z

	def __sub__(self, other):
		return Point(self.x - other.x, self.y - other.y, self.z - other.z)
T = int(input())
for i in range(T):
	points = []
	for j in range(4):
		(Px, Py, Pz) = map(int, input().split())
		points.append(Point(Px, Py, Pz))
	result = (points[2] - points[0]).dot((points[1] - points[0]).cross(points[3] - points[2]))
	if result == 0:
		print('YES')
	else:
		print('NO')


def read_points():
	points = []
	for case in range(4):
		points.append([int(x) for x in input().strip().split()])
	return points

def vector_diff(p1, p2):
	return [x - y for (x, y) in zip(p2, p1)]

def cross_product(p1, p2):
	return [p1[1] * p2[2] - p1[2] * p2[1], p1[0] * p2[2] - p1[2] * p2[0], p1[0] * p2[1] - p1[1] * p2[0]]

def dot_product(v1, v2):
	return sum([x * y for (x, y) in zip(v1, v2)])

def get_surface_normal(p1, p2, p3):
	v1 = vector_diff(p1, p2)
	v2 = vector_diff(p1, p3)
	return cross_product(v1, v2)

def get_plane_const(normal, point):
	return -1 * dot_product(normal, point)

def is_point_in_plane(normal, const, point):
	return dot_product(normal, point) + const == 0
for t in range(int(input())):
	(p1, p2, p3, p4) = read_points()
	normal = get_surface_normal(p1, p2, p3)
	const = get_plane_const(normal, p1)
	print('YES' if is_point_in_plane(normal, const, p4) else 'NO')


def dis_maker(l1, l2, l3, l4):
	status = 'NO\n'
	for i in range(3):
		if lst1[i] == lst2[i] and lst1[i] == lst3[i] and (lst1[i] == lst4[i]):
			status = 'YES\n'
	return status
out = ''
for i in range(int(input())):
	lst1 = [int(x) for x in input().split()]
	lst2 = [int(x) for x in input().split()]
	lst3 = [int(x) for x in input().split()]
	lst4 = [int(x) for x in input().split()]
	out += str(dis_maker(lst1, lst2, lst3, lst4))
print(out[:-1])


def cordinates():
	B = []
	x = []
	y = []
	z = []
	for i in range(0, 4):
		C = input()
		b = [int(i) for i in C.split()]
		x.append(b[0])
		y.append(b[1])
		z.append(b[2])
	B.append(x)
	B.append(y)
	B.append(z)
	satus = 'NO\n'
	for i in B:
		if i[0] == i[1] and i[1] == i[2] and (i[2] == i[3]):
			satus = 'YES\n'
	return satus
out = ''
A = int(input())
for i in range(0, A):
	out += str(cordinates())
print(out[:-1])


t = int(input())
for asdf in range(t):
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	ab = [b[0] - a[0], b[1] - a[1], b[2] - a[2]]
	ac = [c[0] - a[0], c[1] - a[1], c[2] - a[2]]
	abc = [(b[1] - a[1]) * (c[2] - a[2]) - (c[1] - a[1]) * (b[2] - a[2]), (b[2] - a[2]) * (c[0] - a[0]) - (c[2] - a[2]) * (b[0] - a[0]), (b[0] - a[0]) * (c[1] - a[1]) - (c[0] - a[0]) * (b[1] - a[1])]
	con = -(abc[0] * a[0] + abc[1] * a[1] + abc[2] * a[2])
	if d[0] * abc[0] + d[1] * abc[1] + d[2] * abc[2] + con == 0:
		print('YES')
	else:
		print('NO')


num_test = int(input())
for i in range(num_test):
	A = input().split()
	B = input().split()
	C = input().split()
	D = input().split()
	b = [int(C[0]) - int(A[0]), int(C[1]) - int(A[1]), int(C[2]) - int(A[2])]
	a = [int(B[0]) - int(A[0]), int(B[1]) - int(A[1]), int(B[2]) - int(A[2])]
	c = [int(D[0]) - int(A[0]), int(D[1]) - int(A[1]), int(D[2]) - int(A[2])]
	answer = a[0] * (b[1] * c[2] - b[2] * c[1]) - a[1] * (b[0] * c[2] - b[2] * c[0]) + a[2] * (b[0] * c[1] - b[1] * c[0])
	if answer == 0:
		print('YES')
	else:
		print('NO')


num = int(input(''))
for i in range(0, num):
	p = []
	for j in range(0, 4):
		p.append(input('').split(' '))
	(xV, yV, zV) = (1, 1, 1)
	for i in range(1, 4):
		if p[i][0] != p[0][0]:
			xV = 0
		if p[i][1] != p[0][1]:
			yV = 0
		if p[i][2] != p[0][2]:
			zV = 0
	if xV == 1 or yV == 1 or zV == 1:
		print('YES')
	else:
		print('NO')


def IsCoPlanar(P1, P2, P3, P4):
	(x1, y1, z1) = P1
	(x2, y2, z2) = P2
	(x3, y3, z3) = P3
	(x4, y4, z4) = P4
	d = x1 * y2 * z3 - x1 * y2 * z4 - x1 * y3 * z2 + x1 * y3 * z4 + x1 * y4 * z2 - x1 * y4 * z3 - x2 * y1 * z3 + x2 * y1 * z4 + x2 * y3 * z1 - x2 * y3 * z4 - x2 * y4 * z1 + x2 * y4 * z3 + x3 * y1 * z2 - x3 * y1 * z4 - x3 * y2 * z1 + x3 * y2 * z4 + x3 * y4 * z1 - x3 * y4 * z2 - x4 * y1 * z2 + x4 * y1 * z3 + x4 * y2 * z1 - x4 * y2 * z3 - x4 * y3 * z1 + x4 * y3 * z2
	if d == 0:
		return 'YES'
	return 'NO'
T = int(input())
while T:
	T = T - 1
	P1 = [int(i) for i in input().split()]
	P2 = [int(i) for i in input().split()]
	P3 = [int(i) for i in input().split()]
	P4 = [int(i) for i in input().split()]
	print(IsCoPlanar(P1, P2, P3, P4))


t = int(input())
for i in range(t):
	(x1, y1, z1) = map(int, input().split())
	(x2, y2, z2) = map(int, input().split())
	(x3, y3, z3) = map(int, input().split())
	(x4, y4, z4) = map(int, input().split())
	a = (y2 - y1) * (z3 - z1)
	b = (z1 - z2) * (x3 - x1)
	c = (x2 - x1) * (y3 - y1)
	d1 = a * x1 + b * y1 + c * z1
	d2 = a * x4 + b * y4 + c * z4
	if d1 == d2:
		print('YES')
	else:
		print('NO')


def isSamePlane(Ps):
	N = len(Ps[0])
	v1 = [Ps[1][_] - Ps[0][_] for _ in range(N)]
	v2 = [Ps[2][_] - Ps[0][_] for _ in range(N)]
	a = v1[1] * v2[2] - v1[2] * v2[1]
	b = v1[2] * v2[0] - v1[0] * v2[2]
	c = v1[0] * v2[1] - v1[1] * v2[0]
	d = Ps[0][0] * a + Ps[0][1] * b + Ps[0][2] * c
	for p in Ps[3:]:
		if d != p[0] * a + p[1] * b + p[2] * c:
			return False
	return True
T = int(input())
for _ in range(T):
	Ps = [[int(_) for _ in input().split()] for _ in range(4)]
	if isSamePlane(Ps):
		print('YES')
	else:
		print('NO')


def cross(a, b):
	c = [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]]
	return c
T = int(input())
points = []
for i in range(T):
	points1 = []
	for j in range(4):
		(x, y, z) = map(int, input().split())
		points1.append(x)
		points1.append(y)
		points1.append(z)
	points.append(points1)
for x in points:
	e1 = [x[3] - x[0], x[4] - x[1], x[5] - x[2]]
	e2 = [x[6] - x[3], x[7] - x[4], x[8] - x[5]]
	d = [x[9] - x[0], x[10] - x[1], x[11] - x[2]]
	cross_prod = cross(e1, e2)
	dot_prod = sum([d[i] * cross_prod[i] for i in range(3)])
	if dot_prod == 0:
		print('YES')
	else:
		print('NO')


i = int(input())

def crossproduct(x, y):
	for j in range(0, 3):
		z = []
		z += [x[1] * y[2] - x[2] * y[1]]
		z += [x[2] * y[0] - x[0] * y[2]]
		z += [x[0] * y[1] - x[1] * y[0]]
	return z
for _ in range(i):
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	x = [a[0] - b[0], a[1] - b[1], a[2] - b[2]]
	y = [c[0] - b[0], c[1] - b[1], c[2] - b[2]]
	x_d = [a[0] - d[0], a[1] - d[1], a[2] - d[2]]
	y_d = [c[0] - d[0], c[1] - d[1], c[2] - d[2]]
	z = crossproduct(x, y)
	z_d = crossproduct(x_d, y_d)
	dp = z[0] * z_d[0] + z[1] * z_d[1] + z[2] * z_d[2]
	lz = sum([z[m] ** 2 for m in range(0, 3)]) ** 0.5
	lz_d = sum([z_d[m] ** 2 for m in range(0, 3)]) ** 0.5
	if abs(dp) == abs(lz * lz_d):
		print('YES')
	else:
		print('NO')


class Point:

	def __init__(self, name, x, y, z):
		self.name = name
		self.x = x
		self.y = y
		self.z = z

	def __cmp__(self, a):
		if self.x == a.x and self.y == a.y and (self.z == a.z):
			return 1
		else:
			return 0

def cross_product(a, b):
	result = Point('normal', 0, 0, 0)
	result.x = a.y * b.z - a.z * b.y
	result.y = a.z * b.x - a.x * b.z
	result.z = a.x * b.y - a.y * b.x
	return result

def dot_product(a, b):
	return a.x * b.x + a.y * b.y + a.z * b.z
test_cases = int(input())
for i in range(test_cases):
	coordinates = input().split()
	A = Point('A', int(coordinates[0]), int(coordinates[1]), int(coordinates[2]))
	coordinates = input().split()
	B = Point('B', int(coordinates[0]), int(coordinates[1]), int(coordinates[2]))
	coordinates = input().split()
	C = Point('C', int(coordinates[0]), int(coordinates[1]), int(coordinates[2]))
	coordinates = input().split()
	D = Point('D', int(coordinates[0]), int(coordinates[1]), int(coordinates[2]))
	delta_1 = Point('d1', A.x - B.x, A.y - B.y, A.z - B.z)
	delta_2 = Point('d2', A.x - C.x, A.y - C.y, A.z - C.z)
	delta_3 = Point('d3', A.x - D.x, A.y - D.y, A.z - D.z)
	normal = cross_product(delta_1, delta_2)
	result = dot_product(normal, delta_3)
	if result == 0:
		print('YES')
	else:
		print('NO')


trip = lambda : tuple(map(int, input().split()))

def crossProduct(a, b):
	(a1, a2, a3) = a
	(b1, b2, b3) = b
	return (a2 * b3 - a3 * b2, a3 * b1 - a1 * b3, a1 * b2 - a2 * b1)

def diff(a, b):
	(a1, a2, a3) = a
	(b1, b2, b3) = b
	return (a1 - b1, a2 - b2, a3 - b3)
for case in range(int(input())):
	(a, b, c, d) = (trip(), trip(), trip(), trip())
	bc = diff(b, c)
	normal1 = crossProduct(diff(a, b), bc)
	normal2 = crossProduct(diff(c, d), bc)
	print('YES' if crossProduct(normal1, normal2) == (0, 0, 0) else 'NO')


N = int(input())
for i in range(N):
	d = [True] * 3
	r = list(input().split())
	for j in range(3):
		t = list(input().split())
		for k in range(3):
			if r[k] != t[k]:
				d[k] = False
	if sum(d) == 0:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	P1 = list(map(int, input().split()))
	P2 = list(map(int, input().split()))
	P3 = list(map(int, input().split()))
	P4 = list(map(int, input().split()))
	if P1[0] == P2[0] == P3[0] == P4[0]:
		print('YES')
	elif P1[1] == P2[1] == P3[1] == P4[1]:
		print('YES')
	elif P1[2] == P2[2] == P3[2] == P4[2]:
		print('YES')
	else:
		print('NO')


def minor(a, i, j):
	t = []
	for k in range(len(a)):
		if k != i:
			t.append([])
			for l in range(len(a[k])):
				if l != j:
					t[-1].append(a[k][l])
	return t

def det(a):
	if len(a) == 1:
		return a[0][0]
	d = 0
	for i in range(len(a)):
		d += (-1) ** i * a[0][i] * det(minor(a, 0, i))
	return d
for t in range(int(input())):
	a1 = [int(e) for e in input().split()]
	a2 = [int(e) - a1[i] for (i, e) in enumerate(input().split())]
	a3 = [int(e) - a1[i] for (i, e) in enumerate(input().split())]
	a4 = [int(e) - a1[i] for (i, e) in enumerate(input().split())]
	if det([a2, a3, a4]) == 0:
		print('YES')
	else:
		print('NO')


def det(l):
	n = len(l)
	if n > 2:
		i = 1
		t = 0
		sum = 0
		while t <= n - 1:
			d = {}
			t1 = 1
			while t1 <= n - 1:
				m = 0
				d[t1] = []
				while m <= n - 1:
					if m == t:
						u = 0
					else:
						d[t1].append(l[t1][m])
					m += 1
				t1 += 1
			l1 = [d[x] for x in d]
			sum = sum + i * l[0][t] * det(l1)
			i = i * -1
			t += 1
		return sum
	else:
		return l[0][0] * l[1][1] - l[0][1] * l[1][0]
for i in range(int(input())):
	points = []
	vectors = []
	for j in range(4):
		points.append(list(map(int, input().split())))
	for j in [1, 2, 3]:
		v = []
		for k in [0, 1, 2]:
			v.append(points[0][k] - points[j][k])
		vectors.append(v + v)
	print('NO' if det(vectors) else 'YES')


def onSamePlain(x, y, z, x1, y1, z1, x2, y2, z2, x3, y3, z3):
	t1 = (x - x1) * (y2 - y1) * (z3 - z1) + (x2 - x1) * (y3 - y1) * (z - z1) + (x3 - x1) * (z2 - z1) * (y - y1)
	t2 = (z - z1) * (y2 - y1) * (x3 - x1) + (z2 - z1) * (y3 - y1) * (x - x1) + (z3 - z1) * (x2 - x1) * (y - y1)
	return t2 - t1 == 0

def main():
	t = int(input())
	while t:
		(x1, y1, z1) = [int(x) for x in input().split()]
		(x2, y2, z2) = [int(x) for x in input().split()]
		(x3, y3, z3) = [int(x) for x in input().split()]
		(x, y, z) = [int(x) for x in input().split()]
		if onSamePlain(x, y, z, x1, y1, z1, x2, y2, z2, x3, y3, z3):
			print('YES')
		else:
			print('NO')
		t -= 1
main()


def cross(a, b):
	c = [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]]
	return c

def dot(a, b):
	c = a[0] * b[0] + a[1] * b[1] + a[2] * b[2]
	return c
for t in range(int(input())):
	v1 = [int(x) for x in input().split()]
	v2 = [int(x) for x in input().split()]
	v3 = [int(x) for x in input().split()]
	v4 = [int(x) for x in input().split()]
	v12 = [i - j for (i, j) in zip(v2, v1)]
	v13 = [i - j for (i, j) in zip(v3, v1)]
	v14 = [i - j for (i, j) in zip(v4, v1)]
	v123 = cross(v12, v13)
	if dot(v123, v14) == 0:
		print('YES')
	else:
		print('NO')


def check_points(a, b, c, d):
	if collinear(a, b, c):
		return 'YES'
	(u, v) = (vector(a, b), vector(b, c))
	plane = plane_equation(u, v, a)
	return 'YES' if is_on_plane(plane, d) else 'NO'

def collinear(a, b, c):
	return not sum((a[0] * (b[1] - c[1]), +b[0] * (c[1] - a[1]), +c[0] * (a[1] - b[1])))

def is_on_plane(plane, point):
	return not plane[-1] - sum([plane[i] * point[i] for i in range(3)])

def plane_equation(u, v, a):
	n = list(cross_product(u, v))
	n.append(sum([-n[i] * a[i] for i in range(3)]))
	return n

def vector(A, B):
	return tuple((B[i] - A[i] for i in (0, 1, 2)))

def cross_product(u, v):
	return (det(u[1], u[2], v[1], v[2]), det(u[0], u[2], v[0], v[2]), det(u[0], u[1], v[0], v[1]))

def det(a, b, c, d):
	return a * d - b * c

def main():
	tests = int(input())
	for _ in range(tests):
		(a, b, c, d) = [tuple(map(int, input().split(' '))) for _ in range(4)]
		print(check_points(a, b, c, d))
main()


def sub(v1, v2):
	return [v1[i] - v2[i] for i in range(min(len(v1), len(v2)))]

def det(mat):
	if len(mat) == 1:
		return mat[0][0]
	return sum(((-1) ** i * mat[i][0] * det([j[1:] for j in mat[:i] + mat[i + 1:]]) for i in range(len(mat))))
for i in range(int(input())):
	vecs = [[int(j) for j in input().split(' ')] for i in range(4)]
	mat = [sub(vecs[0], vecs[i]) for i in range(1, len(vecs))]
	res = det(mat)
	if res == 0:
		print('YES')
		continue
	print('NO')


__author__ = 'nolanemirot'

def checkIfInSamePlane(arr):
	y = 0
	x = 0
	while x < 3:
		same = True
		y = 0
		tmp = arr[y][x]
		while y < 4:
			if arr[y][x] != tmp:
				same = False
				break
			y += 1
		if same == True:
			return 'YES'
		x += 1
	return 'NO'
nbTestCase = int(input())
indexCase = 0
while indexCase < nbTestCase:
	i = 0
	arr = []
	while i < 4:
		line = input()
		arr.append(list(map(int, line.split())))
		i += 1
	print(checkIfInSamePlane(arr))
	indexCase += 1


import math

class Point(object):

	def __init__(self, line=None, x=None, y=None, z=None):
		if line:
			(self.x, self.y, self.z) = [int(i) for i in line.split()]
		else:
			(self.x, self.y, self.z) = (x, y, z)

	def __sub__(self, point):
		return Point(x=self.x - point.x, y=self.y - point.y, z=self.z - point.z)

	def __isub__(self, point):
		self = self - point
		return self

	def __str__(self):
		return '[%d,%d,%d]' % (self.x, self.y, self.z)

class Matrix(object):

	def __init__(self, rows, cols):
		self.matrix = [[0 for i in range(cols)] for j in range(rows)]
		self.num_rows = rows
		self.num_cols = cols

	def set_point(self, row, point):
		if row > 0 and row <= self.num_rows and (self.num_cols == 3):
			self.matrix[row - 1][0] = point.x
			self.matrix[row - 1][1] = point.y
			self.matrix[row - 1][2] = point.z

	def set(self, row, col, value):
		if row > 0 and row <= self.num_rows and (col > 0) and (col <= self.num_cols):
			self.matrix[row - 1][col - 1] = value

	def get(self, row, col, default=0):
		if row > 0 and row <= self.num_rows and (col > 0) and (col <= self.num_cols):
			return self.matrix[row - 1][col - 1]
		return default

	def determinant(self):
		if self.num_rows == self.num_cols and self.num_rows == 3:
			a = self.get(1, 1) * self.get(2, 2) * self.get(3, 3)
			b = self.get(1, 2) * self.get(2, 3) * self.get(3, 1)
			c = self.get(1, 3) * self.get(2, 1) * self.get(3, 2)
			d = self.get(1, 3) * self.get(2, 2) * self.get(3, 1)
			e = self.get(1, 2) * self.get(2, 1) * self.get(3, 3)
			f = self.get(1, 1) * self.get(2, 3) * self.get(3, 2)
			return a + b + c - (d + e + f)
		return 0

	def __str__(self):
		s = []
		for row in self.matrix:
			s.append('|%s|' % ' '.join([str(x) for x in row]))
		return '\n'.join(s)

def main():
	for case in range(int(input())):
		points = [Point(line=str(input())) for i in range(4)]
		matrix = Matrix(3, 3)
		matrix.set_point(1, points[1] - points[0])
		matrix.set_point(2, points[2] - points[0])
		matrix.set_point(3, points[3] - points[0])
		print('YES' if matrix.determinant() == 0 else 'NO')
main()


def cross(a, b):
	c = [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]]
	return c

def dot(a, b):
	return sum((p * q for (p, q) in zip(a, b)))
t = int(input())
for _ in range(t):
	points = []
	for _ in range(4):
		points.append([int(x) for x in input().split()])
	vecs = []
	for i in range(1, 4):
		vecs.append([ai - a0 for (a0, ai) in zip(points[0], points[i])])
	ans = dot(vecs[0], cross(vecs[1], vecs[2]))
	if ans == 0:
		print('YES')
	else:
		print('NO')


def ans():
	l = []
	boolX = True
	boolY = True
	boolZ = True
	for i in range(4):
		l.append(input().split())
	initialX = l[0][0]
	initialY = l[0][1]
	initialZ = l[0][2]
	for i in l[1:]:
		if i[0] != initialX:
			boolX = False
		if i[1] != initialY:
			boolY = False
		if i[2] != initialZ:
			boolZ = False
	if boolX or boolY or boolZ:
		return 'YES'
	else:
		return 'NO'
for i in range(int(input())):
	print(ans())


T = int(input())

def crossprod(a, b):
	return [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]]

def dotprod(a, b):
	return sum(map(lambda x, y: x * y, a, b))

def subvec(a, b):
	return list(map(lambda x, y: x - y, a, b))
for _ in range(T):
	a = [int(e) for e in input().split()]
	b = [int(e) for e in input().split()]
	c = [int(e) for e in input().split()]
	d = [int(e) for e in input().split()]
	print('YES' if dotprod(crossprod(subvec(b, a), subvec(c, a)), subvec(d, a)) == 0 else 'NO')


T = int(input())
for _ in range(T):
	p1 = input().split()
	p2 = input().split()
	p3 = input().split()
	p4 = input().split()
	on_same_plane = False
	for i in range(3):
		if p1[i] == p2[i] == p3[i] == p4[i]:
			on_same_plane = True
			break
	if not on_same_plane:
		print('NO')
	else:
		print('YES')


def sherlockAndPlanes(arr):
	mat = [[arr[3][0] - arr[0][0], arr[3][1] - arr[0][1], arr[3][2] - arr[0][2]], [arr[3][0] - arr[1][0], arr[3][1] - arr[1][1], arr[3][2] - arr[1][2]], [arr[3][0] - arr[2][0], arr[3][1] - arr[2][1], arr[3][2] - arr[2][2]]]
	det = mat[0][0] * (mat[1][1] * mat[2][2] - mat[2][1] * mat[1][2]) + mat[0][1] * (mat[1][2] * mat[2][0] - mat[1][0] * mat[2][2]) + mat[0][2] * (mat[1][0] * mat[2][1] - mat[1][1] * mat[2][0])
	if det == 0:
		return 'YES'
	else:
		return 'NO'
T = int(input())
for i in range(T):
	arr = []
	for j in range(4):
		arr.append([int(x) for x in input().split()])
	print(sherlockAndPlanes(arr))


for _ in range(int(input())):
	(x1, y1, z1) = [int(x) for x in input().split(' ')]
	(x2, y2, z2) = [int(x) for x in input().split(' ')]
	(x3, y3, z3) = [int(x) for x in input().split(' ')]
	(x4, y4, z4) = [int(x) for x in input().split(' ')]
	tetrahedronArea = x1 * y2 * z3 - x1 * y2 * z4 - x1 * y3 * z2 + x1 * y3 * z4 + x1 * y4 * z2 - x1 * y4 * z3 - x2 * y1 * z3 + x2 * y1 * z4 + x2 * y3 * z1 - x2 * y3 * z4 - x2 * y4 * z1 + x2 * y4 * z3 + x3 * y1 * z2 - x3 * y1 * z4 - x3 * y2 * z1 + x3 * y2 * z4 + x3 * y4 * z1 - x3 * y4 * z2 - x4 * y1 * z2 + x4 * y1 * z3 + x4 * y2 * z1 - x4 * y2 * z3 - x4 * y3 * z1 + x4 * y3 * z2
	print('YES' if tetrahedronArea == 0 else 'NO')


a = int(input())
for i in range(a):
	c = [[], [], [], []]
	for i in range(4):
		c[i] = [int(i) for i in input().split(' ')]
	d = [[], [], []]
	for i in range(3):
		d[i] = [c[i + 1][j] - c[i][j] for j in range(3)]
	det = d[0][0] * (d[1][1] * d[2][2] - d[1][2] * d[2][1]) + d[0][1] * (d[1][2] * d[2][0] - d[1][0] * d[2][2]) + d[0][2] * (d[1][0] * d[2][1] - d[1][1] * d[2][0])
	if det == 0:
		print('YES')
	else:
		print('NO')


for x in range(int(input())):
	(a1, a2, a3) = map(int, input().split())
	(b1, b2, b3) = map(int, input().split())
	(c1, c2, c3) = map(int, input().split())
	(d1, d2, d3) = map(int, input().split())
	ba1 = b1 - a1
	ba2 = b2 - a2
	ba3 = b3 - a3
	ca1 = c1 - a1
	ca2 = c2 - a2
	ca3 = c3 - a3
	da1 = d1 - a1
	da2 = d2 - a2
	da3 = d3 - a3
	deter = ba1 * (ca2 * da3 - ca3 * da2) - ca1 * (ba2 * da3 - ba3 * da2) + da1 * (ba2 * ca3 - ba3 * ca2)
	if deter == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(x1, y1, z1) = input().split()
	(x2, y2, z2) = input().split()
	(x3, y3, z3) = input().split()
	(x4, y4, z4) = input().split()
	(x1, y1, z1) = (int(x1), int(y1), int(z1))
	(x2, y2, z2) = (int(x2), int(y2), int(z2))
	(x3, y3, z3) = (int(x3), int(y3), int(z3))
	(x4, y4, z4) = (int(x4), int(y4), int(z4))
	if x1 == x2 == x3 == x4 or y1 == y2 == y3 == y4 or z1 == z2 == z3 == z4:
		print('YES')
	else:
		print('NO')


numtest = int(input())
for i in range(numtest):
	ans = 'NO'
	num = [[] * 3 for x in range(4)]
	for i in range(4):
		num[i] = list(map(int, input().split()))
	if num[0][0] == num[1][0] and num[1][0] == num[2][0] and (num[2][0] == num[3][0]):
		ans = 'YES'
	elif num[0][1] == num[1][1] and num[1][1] == num[2][1] and (num[2][1] == num[3][1]):
		ans = 'YES'
	elif num[0][2] == num[1][2] and num[1][2] == num[2][2] and (num[2][2] == num[3][2]):
		ans = 'YES'
	print(ans)


import sys

def det2d(a, b, c, d):
	return a * d - b * c

def det3d(A):
	sum = A[0][0] * det2d(A[1][1], A[1][2], A[2][1], A[2][2])
	sum -= A[0][1] * det2d(A[1][0], A[1][2], A[2][0], A[2][2])
	sum += A[0][2] * det2d(A[1][0], A[1][1], A[2][0], A[2][1])
	return sum
source = sys.stdin
T = int(source.readline())
for _ in range(T):
	vectors = []
	for i in range(4):
		vectors.append([int(s) for s in source.readline().split()])
	for i in range(1, 4):
		vectors[i] = [b - a for (a, b) in zip(vectors[0], vectors[i])]
	A = vectors[1:]
	if det3d(A) == 0:
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	s = 0
	a = []
	for i in range(4):
		a.append(input().split())
		a[i] = list(map(int, a[i]))
	for i in range(3):
		for j in range(3):
			a[i][j] -= a[3][j]
	d = 0
	for i in range(3):
		s += a[0][i] * a[1][(i + 1) % 3] * a[2][(i + 2) % 3]
		s -= a[0][i] * a[1][(i - 1) % 3] * a[2][(i - 2) % 3]
	if s == 0:
		print('YES')
	else:
		print('NO')


T = int(input())

def det3(matrix):
	d = 0
	for i in range(3):
		matrix[i] = matrix[i] + matrix[i][0:2]
	for i in range(3):
		prod1 = 1
		prod2 = 1
		for j in range(3):
			prod1 *= matrix[j][j + i]
			prod2 *= matrix[j][-j - 1 - i]
		d = d + prod1 - prod2
	return d

def det4(a):
	sum = 0
	for i in range(4):
		c = []
		for j in range(1, 4):
			c.append(a[j][0:i] + a[j][i + 1:])
		sum = sum + (-1) ** i * a[0][i] * det3(c)
	return sum
for tt in range(T):
	m = []
	for i in range(4):
		row = list(map(int, input().split()))
		m.append(row + [1])
	print('YES' if det4(m) == 0 else 'NO')


t = int(input())
for _ in range(t):
	p0 = tuple(map(int, input().split()))
	p1 = map(int, input().split())
	p2 = map(int, input().split())
	p3 = map(int, input().split())
	v01 = [i1 - i0 for (i0, i1) in zip(p0, p1)]
	v02 = [i2 - i0 for (i0, i2) in zip(p0, p2)]
	v03 = [i3 - i0 for (i0, i3) in zip(p0, p3)]
	n = (v01[1] * v02[2] - v01[2] * v02[1], v01[2] * v02[0] - v01[0] * v02[2], v01[0] * v02[1] - v01[1] * v02[0])
	d = sum((i * i3 for (i, i3) in zip(n, v03)))
	print('YES' if d == 0 else 'NO')


T = int(input())
for _ in range(T):
	a = input().split()
	b = input().split()
	c = input().split()
	d = input().split()
	p = [0] * 3
	q = [0] * 3
	r = [0] * 3
	for i in range(3):
		a[i] = int(a[i])
		b[i] = int(b[i])
		c[i] = int(c[i])
		d[i] = int(d[i])
		p[i] = b[i] - a[i]
		q[i] = c[i] - a[i]
		r[i] = d[i] - a[i]
	V = p[0] * q[1] * r[2] + p[1] * q[2] * r[0] + p[2] * q[0] * r[1] - p[0] * q[2] * r[1] - p[1] * q[0] * r[2] - p[2] * q[1] * r[0]
	if V == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	t1 = list(map(int, input().split()))
	t2 = list(map(int, input().split()))
	t3 = list(map(int, input().split()))
	t4 = list(map(int, input().split()))
	z = list(map(set, zip(t1, t2, t3, t4)))
	if len(z[0]) == 1 or len(z[1]) == 1 or len(z[2]) == 1:
		print('YES')
	else:
		print('NO')


def on_same_plane(p1, p2, p3, p4):
	det1 = (p1[1] - p3[1]) * (p1[2] - p4[2]) - (p1[1] - p4[1]) * (p1[2] - p3[2])
	det2 = (p1[0] - p3[0]) * (p1[2] - p4[2]) - (p1[0] - p4[0]) * (p1[2] - p3[2])
	det3 = (p1[0] - p3[0]) * (p1[1] - p4[1]) - (p1[0] - p4[0]) * (p1[1] - p3[1])
	a = (p1[0] - p2[0]) * det1
	b = (p1[1] - p2[1]) * det2
	c = (p1[2] - p2[2]) * det3
	return a + b + c == 0
t = int(input())
for _ in range(t):
	t1 = [int(el) for el in input().split()]
	t2 = [int(el) for el in input().split()]
	t3 = [int(el) for el in input().split()]
	t4 = [int(el) for el in input().split()]
	print('YES' if on_same_plane(t1, t2, t3, t4) else 'NO')


T = int(input())
for _ in range(T):
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = [int(i) for i in input().split()]
	d = [int(i) for i in input().split()]
	ab = [b[i] - a[i] for i in range(3)]
	ac = [c[i] - a[i] for i in range(3)]
	ad = [d[i] - a[i] for i in range(3)]
	n = [ab[1] * ac[2] - ab[2] * ac[1], ab[2] * ac[0] - ab[0] * ac[2], ab[0] * ac[1] - ab[1] * ac[0]]
	nad = sum([n[i] * ad[i] for i in range(3)])
	print('YES' if nad == 0 else 'NO')


import sys
T = int(sys.stdin.readline())
for _ in range(T):
	A = list(map(int, sys.stdin.readline().split()))
	B = list(map(int, sys.stdin.readline().split()))
	C = list(map(int, sys.stdin.readline().split()))
	D = list(map(int, sys.stdin.readline().split()))
	AB = [x - y for (x, y) in zip(B, A)]
	AC = [x - y for (x, y) in zip(C, A)]
	AD = [x - y for (x, y) in zip(D, A)]
	V = AB[0] * (AC[1] * AD[2] - AC[2] * AD[1])
	V += AB[1] * (AC[0] * AD[2] - AC[2] * AD[0])
	V += AB[2] * (AC[0] * AD[1] - AC[1] * AD[0])
	print('YES' if V == 0 else 'NO')


import sys
T = int(sys.stdin.readline())
for _ in range(T):
	A = list(map(int, sys.stdin.readline().split()))
	B = list(map(int, sys.stdin.readline().split()))
	C = list(map(int, sys.stdin.readline().split()))
	D = list(map(int, sys.stdin.readline().split()))
	AB = [x - y for (x, y) in zip(B, A)]
	AC = [x - y for (x, y) in zip(C, A)]
	AD = [x - y for (x, y) in zip(D, A)]
	V = AB[0] * (AC[1] * AD[2] - AC[2] * AD[1])
	V += AB[1] * (AC[0] * AD[2] - AC[2] * AD[0])
	V += AB[2] * (AC[0] * AD[1] - AC[1] * AD[0])
	print('YES' if V == 0 else 'NO')


def linear2d(matrix):
	if matrix[0][0] != 0:
		matrix[0] = [x / matrix[0][0] for x in matrix[0]]
	matrix[1] = [y - x * matrix[1][0] for (x, y) in zip(matrix[0], matrix[1])]
	if matrix[1][1] != 0:
		matrix[1] = [y / matrix[1][1] for y in matrix[1]]
	matrix[0] = [x - y * matrix[0][1] for (x, y) in zip(matrix[0], matrix[1])]
	return (matrix[0][2], matrix[1][2])

def check_points(x1, x2, x3, x4):
	for (p1, p2, p3, p4) in zip(x1, x2, x3, x4):
		if p1 == p2 and p2 == p3 and (p3 == p4):
			return True
	v12 = [p2 - p1 for (p1, p2) in zip(x1, x2)]
	v13 = [p3 - p1 for (p1, p3) in zip(x1, x3)]
	(a, b) = linear2d([[v12[0], v13[0], x4[0] - x1[0]], [v12[1], v13[1], x4[1] - x1[1]]])
	guess_x4 = [x1p + a * v12p + b * v13p for (x1p, v12p, v13p) in zip(x1, v12, v13)]
	return guess_x4 == x4
cases = int(input())
for case in range(cases):
	x1 = [int(s) for s in input().split()]
	x2 = [int(s) for s in input().split()]
	x3 = [int(s) for s in input().split()]
	x4 = [int(s) for s in input().split()]
	if check_points(x1, x2, x3, x4):
		print('YES')
	else:
		print('NO')


T = int(input())
for i in range(0, T):
	L = list()
	for j in range(0, 4):
		curP_line = str(input())
		curP_line_split = curP_line.split(' ')
		curP = [int(x) for x in curP_line_split]
		L.append(curP)
	V1 = [L[0][0] - L[1][0], L[0][1] - L[1][1], L[0][2] - L[1][2]]
	V2 = [L[2][0] - L[1][0], L[2][1] - L[1][1], L[2][2] - L[1][2]]
	V3 = [L[0][0] - L[2][0], L[0][1] - L[2][1], L[0][2] - L[2][2]]
	Det = V1[0] * V2[1] * V3[2] + V1[1] * V2[2] * V3[0] + V1[2] * V2[0] * V3[1]
	if Det == 0:
		print('YES')
	else:
		print('NO')


import sys
T = int(sys.stdin.readline())
for _ in range(T):
	A = list(map(int, sys.stdin.readline().split()))
	B = list(map(int, sys.stdin.readline().split()))
	C = list(map(int, sys.stdin.readline().split()))
	D = list(map(int, sys.stdin.readline().split()))
	AB = [x - y for (x, y) in zip(B, A)]
	AC = [x - y for (x, y) in zip(C, A)]
	AD = [x - y for (x, y) in zip(D, A)]
	V = AB[0] * (AC[1] * AD[2] - AC[2] * AD[1])
	V += AB[1] * (AC[0] * AD[2] - AC[2] * AD[0])
	V += AB[2] * (AC[0] * AD[1] - AC[1] * AD[0])
	print('YES' if V == 0 else 'NO')


T = int(input())
tests = []
for test in range(T):
	quad = []
	for point in range(4):
		quad.append([int(i) for i in input().split()])
	tests.append(quad)

def cross_product(a, b):
	(a1, a2, a3) = a
	(b1, b2, b3) = b
	return (a2 * b3 - a3 * b2, a3 * b1 - a1 * b3, a1 * b2 - a2 * b1)
for test in tests:
	(A, B, C, D) = test
	AB = [B[i] - A[i] for i in range(3)]
	AC = [C[i] - A[i] for i in range(3)]
	normal = cross_product(AB, AC)
	(x, y, z) = D
	(a, b, c) = normal
	(x0, y0, z0) = A
	if a * (x - x0) + b * (y - y0) + c * (z - z0) == 0:
		print('YES')
	else:
		print('NO')


def cross_prod(u1, u2, u3, v1, v2, v3):
	w1 = u2 * v3 - u3 * v2
	w2 = u3 * v1 - u1 * v3
	w3 = u1 * v2 - u2 * v1
	return (w1, w2, w3)

def dot_prod(u1, u2, u3, v1, v2, v3):
	res = u1 * v1 + u2 * v2 + u3 * v3
	return res

def vect(x1, x2, x3, y1, y2, y3):
	z1 = y1 - x1
	z2 = y2 - x2
	z3 = y3 - x3
	return (z1, z2, z3)

def are_coplanar():
	(xa, ya, za) = map(int, input().split())
	(xb, yb, zb) = map(int, input().split())
	(xc, yc, zc) = map(int, input().split())
	(xd, yd, zd) = map(int, input().split())
	(xab, yab, zab) = vect(xa, ya, za, xb, yb, zb)
	(xac, yac, zac) = vect(xa, ya, za, xc, yc, zc)
	(xad, yad, zad) = vect(xa, ya, za, xd, yd, zd)
	(xn, yn, zn) = cross_prod(xab, yab, zab, xac, yac, zac)
	if dot_prod(xn, yn, zn, xad, yad, zad):
		print('NO')
	else:
		print('YES')

def main():
	t = int(input())
	for x in range(t):
		are_coplanar()
main()


def eq(sth):
	return len(set(sth)) == 1
for _ in range(int(input())):
	(x, y, z) = map(int, input().split(' '))
	for _ in range(3):
		(i, j, k) = map(int, input().split(' '))
		if i != x:
			x = -1
		if j != y:
			y = -1
		if k != z:
			z = -1
	if len(set([x, y, z])) == 1:
		print('NO')
	else:
		print('YES')


import sys
T = int(sys.stdin.readline())
for _ in range(T):
	A = list(map(int, sys.stdin.readline().split()))
	B = list(map(int, sys.stdin.readline().split()))
	C = list(map(int, sys.stdin.readline().split()))
	D = list(map(int, sys.stdin.readline().split()))
	AB = [x - y for (x, y) in zip(B, A)]
	AC = [x - y for (x, y) in zip(C, A)]
	AD = [x - y for (x, y) in zip(D, A)]
	V = AB[0] * (AC[1] * AD[2] - AC[2] * AD[1])
	V += AB[1] * (AC[0] * AD[2] - AC[2] * AD[0])
	V += AB[2] * (AC[0] * AD[1] - AC[1] * AD[0])
	print('YES' if V == 0 else 'NO')


import sys
T = int(sys.stdin.readline())
for _ in range(T):
	A = list(map(int, sys.stdin.readline().split()))
	B = list(map(int, sys.stdin.readline().split()))
	C = list(map(int, sys.stdin.readline().split()))
	D = list(map(int, sys.stdin.readline().split()))
	AB = [x - y for (x, y) in zip(B, A)]
	AC = [x - y for (x, y) in zip(C, A)]
	AD = [x - y for (x, y) in zip(D, A)]
	V = AB[0] * (AC[1] * AD[2] - AC[2] * AD[1])
	V += AB[1] * (AC[0] * AD[2] - AC[2] * AD[0])
	V += AB[2] * (AC[0] * AD[1] - AC[1] * AD[0])
	print('YES' if V == 0 else 'NO')


def cross(A, B):
	return [A[1] * B[2] - A[2] * B[1], A[2] * B[0] - A[0] * B[2], A[0] * B[1] - A[1] * B[0]]

def dot(A, B):
	return sum([x * y for (x, y) in zip(A, B)])
t = int(input())
for _ in range(t):
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	C = list(map(int, input().split()))
	D = list(map(int, input().split()))
	AB = [x - y for (x, y) in zip(B, A)]
	AC = [x - y for (x, y) in zip(C, A)]
	n = cross(AB, AC)
	d = dot(A, n)
	print('YES' if dot(D, n) == d else 'NO')


num = int(input())
for n in range(0, num):
	l = []
	for j in range(0, 4):
		l.append([int(i) for i in input().split(' ')])
	setX = set()
	setY = set()
	setZ = set()
	for i in l:
		setX.add(i[0])
		setY.add(i[1])
		setZ.add(i[2])
	if len(setX) <= 2 or len(setY) <= 2 or len(setZ) <= 2:
		print('YES')
	else:
		print('NO')


import math
EPSI = 1e-08

def vecEq(v0, v1):
	return abs(v0[0] - v1[0]) <= EPSI and abs(v0[1] - v1[1]) <= EPSI and (abs(v0[2] - v1[2]) <= EPSI)

def norm(v):
	vlen = math.sqrt(v[0] ** 2 + v[1] ** 2 + v[2] ** 2)
	return [v[0] / vlen, v[1] / vlen, v[2] / vlen]

def p2p(p0, p1):
	return [p0[0] - p1[0], p0[1] - p1[1], p0[2] - p1[2]]

def neg(v):
	return [-v[0], -v[1], -v[2]]

def isLine(p0, p1, p2):
	if vecEq(p0, p1) or vecEq(p0, p2) or vecEq(p1, p2):
		return True
	v0 = p2p(p0, p1)
	v1 = p2p(p0, p2)
	v0 = norm(v0)
	v1 = norm(v1)
	return vecEq(v0, v1) or vecEq(v0, neg(v1))

def cross(a, b):
	return [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]]
t = int(input())
for _ in range(t):
	p0 = list(map(int, input().split()))
	p1 = list(map(int, input().split()))
	p2 = list(map(int, input().split()))
	p3 = list(map(int, input().split()))
	if isLine(p0, p1, p2) or isLine(p1, p2, p3):
		print('YES')
	else:
		c0 = cross(p2p(p0, p1), p2p(p0, p2))
		c1 = cross(p2p(p1, p2), p2p(p1, p3))
		c0 = norm(c0)
		c1 = norm(c1)
		b = vecEq(c0, c1) or vecEq(c0, neg(c1))
		print('YES' if b else 'NO')


def diff(a, b):
	return [a[0] - b[0], a[1] - b[1], a[2] - b[2]]

def dot(a, b):
	return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]

def cross(a, b):
	return [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]]
for i in range(int(input())):
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	if dot(cross(diff(a, b), diff(a, c)), diff(a, d)) == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	i = 0
	val = 'NO'
	while i < 3:
		if a[i] == b[i] and b[i] == c[i] and (c[i] == d[i]):
			i = 3
			val = 'YES'
		i += 1
	print(val)


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

def simplify(a):
	GCD = gcd(gcd(abs(a[0]), abs(a[1])), abs(a[2]))
	if GCD:
		a[0] //= GCD
		a[1] //= GCD
		a[2] //= GCD
	return a

def neg(a):
	return [-a[0], -a[1], -a[2]]

def diff(a, b):
	return [a[0] - b[0], a[1] - b[1], a[2] - b[2]]

def cross(u, v):
	return [u[1] * v[2] - u[2] * v[1], u[2] * v[0] - u[0] * v[2], u[0] * v[1] - u[1] * v[0]]

def plane(p, q, r):
	return simplify(cross(diff(q, p), diff(r, p)))
for _ in range(int(input())):
	p = list(map(int, input().split()))
	q = list(map(int, input().split()))
	r = list(map(int, input().split()))
	s = list(map(int, input().split()))
	plane1 = plane(p, q, r)
	plane2 = plane(p, q, s)
	print('YES' if plane1 == [0, 0, 0] or plane2 == [0, 0, 0] or plane1 == plane2 or (neg(plane1) == plane2) else 'NO')


for _ in range(int(input())):
	(x1, y1, z1) = [int(ns) for ns in str(input()).split()]
	(x2, y2, z2) = [int(ns) for ns in str(input()).split()]
	(x3, y3, z3) = [int(ns) for ns in str(input()).split()]
	(x4, y4, z4) = [int(ns) for ns in str(input()).split()]
	a1 = x1 - x2
	a2 = y1 - y2
	a3 = z1 - z2
	b1 = x1 - x3
	b2 = y1 - y3
	b3 = z1 - z3
	c1 = x1 - x4
	c2 = y1 - y4
	c3 = z1 - z4
	d1 = a2 * b3 - a3 * b2
	d2 = a3 * b1 - a1 * b3
	d3 = a1 * b2 - a2 * b1
	if c1 * d1 + c2 * d2 + c3 * d3 == 0:
		print('YES')
	else:
		print('NO')


x = 0
y = 1
z = 2

def getTestCase():
	lines = 4
	case = []
	for i in range(lines):
		case.append(input().split())
	return case

def getPlane(testCase, plane):
	values = []
	for i in range(len(testCase)):
		values.append(testCase[i][plane])
	return values

def checkPlane(values):
	if all((e == values[0] for e in values)):
		return True
	else:
		return False
n = int(input())
for i in range(n):
	case = getTestCase()
	xVal = getPlane(case, x)
	yVal = getPlane(case, y)
	zVal = getPlane(case, z)
	if checkPlane(xVal) or checkPlane(yVal) or checkPlane(zVal):
		print('YES')
	else:
		print('NO')


T = int(input())
for _ in range(T):
	sets = [set(), set(), set()]
	for i in range(4):
		(x, y, z) = map(int, input().split())
		sets[0].add(x)
		sets[1].add(y)
		sets[2].add(z)
	if len(sets[0]) == 1 or len(sets[1]) == 1 or len(sets[2]) == 1:
		print('YES')
	else:
		print('NO')


for a in range(0, int(input())):
	(ax, ay, az) = [int(i) for i in input().split()]
	(bx, by, bz) = [int(i) for i in input().split()]
	(cx, cy, cz) = [int(i) for i in input().split()]
	(dx, dy, dz) = [int(i) for i in input().split()]
	bx = bx - ax
	cx = cx - ax
	dx = dx - ax
	by = by - ay
	cy = cy - ay
	dy = dy - ay
	bz = bz - az
	cz = cz - az
	dz = dz - az
	x = by * cz - bz * cy
	y = bx * cz - bz * cx
	z = bx * cy - by * cx
	if dx * x + dy * y + dz * z == 0:
		print('YES')
	else:
		print('NO')


t = int(input().strip())
for i in range(t):
	(x1, y1, z1) = input().strip().split(' ')
	(x1, y1, z1) = (int(x1), int(y1), int(z1))
	(x2, y2, z2) = input().strip().split(' ')
	(x2, y2, z2) = (int(x2), int(y2), int(z2))
	(x3, y3, z3) = input().strip().split(' ')
	(x3, y3, z3) = (int(x3), int(y3), int(z3))
	(x4, y4, z4) = input().strip().split(' ')
	(x4, y4, z4) = (int(x4), int(y4), int(z4))
	(vx1, vy1, vz1) = (x2 - x1, y2 - y1, z2 - z1)
	(vx2, vy2, vz2) = (x3 - x1, y3 - y1, z3 - z1)
	(vx3, vy3, vz3) = (x4 - x1, y4 - y1, z4 - z1)
	(cx, cy, cz) = (vy1 * vz2 - vz1 * vy2, -1 * (vx1 * vz2 - vz1 * vx2), vx1 * vy2 - vy1 * vx2)
	if cx * vx3 + cy * vy3 + cz * vz3 == 0:
		print('YES')
	else:
		print('NO')


import sys
T = int(sys.stdin.readline())
for t in range(T):
	points = [[int(x) for x in sys.stdin.readline().split()] for i in range(4)]
	L = [[points[i][j] - points[3][j] for j in range(3)] for i in range(3)]
	(L1, L2, L3) = (L[0], L[1], L[2])
	perp = [L1[1] * L2[2] - L1[2] * L2[1], L1[2] * L2[0] - L1[2] * L2[0], L1[0] * L2[1] - L1[1] * L2[0]]
	dot = sum([a * b for (a, b) in zip(perp, L3)])
	print('YES' if dot == 0 else 'NO')


n = int(input().strip())
k = []
for i in range(n):
	k1 = [int(x) for x in input().strip().split(' ')]
	k2 = [int(x) for x in input().strip().split(' ')]
	k3 = [int(x) for x in input().strip().split(' ')]
	k4 = [int(x) for x in input().strip().split(' ')]
	k += [[k1, k2, k3, k4]]
odgovor = 'NO'
for x in k:
	x1 = x[0]
	x2 = x[1]
	x3 = x[2]
	x4 = x[3]
	y1 = [x1[0] - x2[0], x1[1] - x2[1], x1[2] - x2[2]]
	y2 = [x3[0] - x2[0], x3[1] - x2[1], x3[2] - x2[2]]
	xx = [y1[1] * y2[2] - y1[2] * y2[1], y1[2] * y2[0] - y1[0] * y2[2], y1[0] * y2[1] - y1[1] * y2[0]]
	z = x3[0] * xx[0] + x3[1] * xx[1] + x3[2] * xx[2]
	if x4[0] * xx[0] + x4[1] * xx[1] + x4[2] * xx[2] == z:
		odgovor = 'YES'
	print(odgovor)
	odgovor = 'NO'


n = int(input())
for i in range(0, n):
	point1 = input().split()
	(A1, B1, C1) = (int(point1[0]), int(point1[1]), int(point1[2]))
	point2 = input().split()
	(A2, B2, C2) = (int(point2[0]) - A1, int(point2[1]) - B1, int(point2[2]) - C1)
	point3 = input().split()
	(A3, B3, C3) = (int(point3[0]) - A1, int(point3[1]) - B1, int(point3[2]) - C1)
	point4 = input().split()
	(A4, B4, C4) = (int(point4[0]) - A1, int(point4[1]) - B1, int(point4[2]) - C1)
	det = A2 * (B3 * C4 - C3 * B4) - B2 * (A3 * C4 - C3 * A4) + C2 * (A3 * B4 - A4 * B3)
	if det == 0:
		print('YES')
	else:
		print('NO')


import math

def vectorize(A, B):
	x = []
	for i in range(3):
		x.append(B[i] - A[i])
	return x

def cross(A, B):
	x = []
	x.append(A[1] * B[2] - B[1] * A[2])
	x.append(A[2] * B[0] - B[2] * A[0])
	x.append(A[0] * B[1] - B[0] * A[1])
	return x

def dot(A, B):
	count = 0
	for i in range(3):
		count += A[i] * B[i]
	return count
for i in range(int(input())):
	point = []
	point.append([int(i) for i in input().split()])
	point.append([int(i) for i in input().split()])
	point.append([int(i) for i in input().split()])
	point.append([int(i) for i in input().split()])
	A = vectorize(point[0], point[1])
	B = vectorize(point[0], point[2])
	C = vectorize(point[0], point[3])
	if not dot(C, cross(A, B)):
		print('YES')
	else:
		print('NO')


T = int(input())
for _ in range(T):
	l = []
	l.append(list(map(int, input().split(' '))))
	l.append(list(map(int, input().split(' '))))
	l.append(list(map(int, input().split(' '))))
	l.append(list(map(int, input().split(' '))))
	if all((l[i][2] == l[0][2] for i in range(0, 4))) or all((l[i][1] == l[0][1] for i in range(0, 4))) or all((l[i][0] == l[0][0] for i in range(0, 4))):
		print('YES')
	else:
		print('NO')


test = int(input())
for t in range(test):
	(flag1, flag2, flag3, j, k, l) = (0, 0, 0, 0, 0, 0)
	point = []
	for i in range(4):
		point.append([int(x) for x in input().split()])
	while flag1 == 0 and k != len(point) - 1:
		k += 1
		if point[0][0] != point[k][0]:
			flag1 = 1
	while flag2 == 0 and j != len(point) - 1:
		j += 1
		if point[0][1] != point[j][1]:
			flag2 = 1
	while flag3 == 0 and l != len(point) - 1:
		l += 1
		if point[0][2] != point[l][2]:
			flag3 = 1
	if flag1 == 0 or flag2 == 0 or flag3 == 0:
		print('YES')
	elif flag1 == flag2 == flag3 == 1:
		print('NO')


def cross_product(a, b):
	c = [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]]
	return c
t = int(input())
for _ in range(t):
	base = list(map(int, input().split()))
	v = []
	for i in range(3):
		v += [[v_i - b_i for (v_i, b_i) in zip(map(int, input().split()), base)]]
	if cross_product(cross_product(v[0], v[1]), cross_product(v[1], v[2])) == [0, 0, 0]:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(x1, y1, z1) = map(int, input().strip().split())
	(x2, y2, z2) = map(int, input().strip().split())
	(x3, y3, z3) = map(int, input().strip().split())
	(x4, y4, z4) = map(int, input().strip().split())
	v1 = [x3 - x1, y3 - y1, z3 - z1]
	v2 = [x2 - x1, y2 - y1, z2 - z1]
	cp = [v1[1] * v2[2] - v1[2] * v2[1], v1[2] * v2[0] - v1[0] * v2[2], v1[0] * v2[1] - v1[1] * v2[0]]
	(a, b, c) = cp
	d = a * x1 + b * y1 + c * z1
	if d == a * x4 + b * y4 + c * z4:
		print('YES')
	else:
		print('NO')


import sys
t = int(input().strip())
for a0 in range(t):
	(x1, y1, z1) = input().strip().split(' ')
	(x1, y1, z1) = [int(x1), int(y1), int(z1)]
	(x2, y2, z2) = input().strip().split(' ')
	(x2, y2, z2) = [int(x2), int(y2), int(z2)]
	(x3, y3, z3) = input().strip().split(' ')
	(x3, y3, z3) = [int(x3), int(y3), int(z3)]
	(x4, y4, z4) = input().strip().split(' ')
	(x4, y4, z4) = [int(x4), int(y4), int(z4)]
	c1 = (x4 - x1) * ((y2 - y1) * (z3 - z1) - (z2 - z1) * (y3 - y1))
	c2 = (y4 - y1) * ((z2 - z1) * (x3 - x1) - (x2 - x1) * (z3 - z1))
	c3 = (z4 - z1) * ((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1))
	if c1 + c2 + c3 == 0:
		print('YES')
	else:
		print('NO')


def cross_prod(A, B, C):
	tmp1 = A[0] * B[1] * C[2] + A[1] * B[2] * C[0] + A[2] * B[0] * C[1]
	tmp2 = A[2] * B[1] * C[0] + A[1] * B[0] * C[2] + A[0] * B[2] * C[1]
	return tmp1 - tmp2
case_count = int(input())
for i in range(case_count):
	A = [int(x) for x in input().split(' ')]
	B = [int(x) for x in input().split(' ')]
	C = [int(x) for x in input().split(' ')]
	D = [int(x) for x in input().split(' ')]
	AB = [B[0] - A[0], B[1] - A[1], B[2] - A[2]]
	AC = [C[0] - A[0], C[1] - A[1], C[2] - A[2]]
	AD = [D[0] - A[0], D[1] - A[1], D[2] - A[2]]
	if cross_prod(AB, AC, AD) == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
for goes in range(n):
	x = []
	y = []
	z = []
	for case in range(4):
		lines = input()
		numbs = lines.split()
		x.append(numbs[0])
		y.append(numbs[1])
		z.append(numbs[2])
	if x[0] == x[1] == x[2] == x[3] or y[0] == y[1] == y[2] == y[3] or z[0] == z[1] == z[2] == z[3]:
		print('YES')
	else:
		print('NO')


def read_vec():
	return [int(x) for x in input().split()]

def diff_vec(a, b):
	return [a[0] - b[0], a[1] - b[1], a[2] - b[2]]

def triple_prod(a, b, c):
	return a[0] * b[1] * c[2] + a[1] * b[2] * c[0] + a[2] * b[0] * c[1] - a[0] * b[2] * c[1] - a[1] * b[0] * c[2] - a[2] * b[1] * c[0]
T = int(input())
for case in range(T):
	p1 = read_vec()
	p2 = read_vec()
	p3 = read_vec()
	p4 = read_vec()
	p = triple_prod(diff_vec(p2, p1), diff_vec(p3, p1), diff_vec(p4, p1))
	if p == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	(x1, y1, z1) = [int(x) for x in input().split()]
	(x2, y2, z2) = [int(x) for x in input().split()]
	(x3, y3, z3) = [int(x) for x in input().split()]
	(x4, y4, z4) = [int(x) for x in input().split()]
	(x1, y1, z1) = (x1 - x4, y1 - y4, z1 - z4)
	(x2, y2, z2) = (x2 - x4, y2 - y4, z2 - z4)
	(x3, y3, z3) = (x3 - x4, y3 - y4, z3 - z4)
	if 0 == x1 * (y2 * z3 - z2 * y3) - y1 * (x2 * z3 - x3 * z2) + z1 * (x2 * y3 - x3 * y2):
		print('YES')
	else:
		print('NO')
	t -= 1


num_cases = int(input())
while num_cases > 0:
	num_cases -= 1
	result_point = [True, True, True]
	last_point = [int(x) for x in input().split(' ')]
	points_left = 3
	while points_left > 0:
		points_left -= 1
		point = [int(x) for x in input().split(' ')]
		result_point = [valid and x == y for (valid, x, y) in zip(result_point, point, last_point)]
		if result_point == [False, False, False]:
			print('NO')
			while points_left > 0:
				points_left -= 1
				input()
			break
		last_point = point
	if True in result_point:
		print('YES')


T = int(input())
for t in range(T):
	A = list(map(int, input().strip().split()))
	B = list(map(int, input().strip().split()))
	C = list(map(int, input().strip().split()))
	D = list(map(int, input().strip().split()))
	X = [0, 0, 0]
	Y = [0, 0, 0]
	Z = [0, 0, 0]
	for j in range(3):
		X[j] = B[j] - A[j]
		Y[j] = C[j] - A[j]
		Z[j] = D[j] - A[j]
	res = X[0] * Y[1] * Z[2] + X[1] * Y[2] * Z[0] + X[2] * Y[0] * Z[1] - X[2] * Y[1] * Z[0] - X[0] * Y[2] * Z[1] - X[1] * Y[0] * Z[2]
	if res:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(x1, y1, z1) = map(int, input().split())
	(x2, y2, z2) = map(int, input().split())
	(x3, y3, z3) = map(int, input().split())
	(x4, y4, z4) = map(int, input().split())
	a = (y2 - y1) * (z3 - z1)
	b = -1 * (z2 - z1) * (x3 - x1)
	c = (x2 - x1) * (y3 - y1)
	d = a * x1 + b * y1 + c * z1
	if d == a * x4 + b * y4 + c * z4:
		print('YES')
	else:
		print('NO')


for case in range(int(input())):
	a = tuple((int(word) for word in input().split()))
	b = tuple((int(word) for word in input().split()))
	c = tuple((int(word) for word in input().split()))
	d = tuple((int(word) for word in input().split()))
	z = zip(a, b, c, d)
	result = False
	for i in z:
		if len(set(i)) == 1:
			result = True
	print('YES' if result else 'NO')


for _ in range(int(input())):
	O = [int(x) for x in input().split()]
	A = [int(x) - O[i] for (i, x) in enumerate(input().split())]
	B = [int(x) - O[i] for (i, x) in enumerate(input().split())]
	C = [int(x) - O[i] for (i, x) in enumerate(input().split())]
	Triple = C[0] * (A[1] * B[2] - A[2] * B[1]) + C[1] * (A[2] * B[0] - A[0] * B[2]) + C[2] * (A[0] * B[1] - A[1] * B[0])
	if Triple == 0:
		print('YES')
	else:
		print('NO')


import sys
res = []
n = int(input().strip())

def cross(a, b):
	c = [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]]
	return c
for i in range(n):
	(a0, a1, a2) = input().strip().split(' ')
	A = [int(a0), int(a1), int(a2)]
	(b0, b1, b2) = input().strip().split(' ')
	B = [int(b0), int(b1), int(b2)]
	(c0, c1, c2) = input().strip().split(' ')
	C = [int(c0), int(c1), int(c2)]
	(d0, d1, d2) = input().strip().split(' ')
	D = [int(d0), int(d1), int(d2)]
	vect1 = [B[0] - A[0], B[1] - A[1], B[2] - A[2]]
	vect2 = [C[0] - A[0], C[1] - A[1], C[2] - A[2]]
	cross1 = cross(vect1, vect2)
	vect3 = [D[0] - A[0], D[1] - A[1], D[2] - A[2]]
	if cross1[0] * vect3[0] + cross1[1] * vect3[1] + cross1[2] * vect3[2] == 0:
		res.append('YES')
	else:
		res.append('NO')
for i in range(n):
	print(res[i])


def read_ints():
	return [int(x) for x in input().strip().split(' ')]

def read_int():
	return int(input().strip())
T = read_int()
for t in range(T):
	(ax, ay, az) = read_ints()
	(bx, by, bz) = read_ints()
	(cx, cy, cz) = read_ints()
	(dx, dy, dz) = read_ints()
	x = ax == bx == cx == dx
	y = ay == by == cy == dy
	z = az == bz == cz == dz
	if x or y or z:
		print('YES')
	else:
		print('NO')


def crossProd(x, y):
	return [x[1] * y[2] - x[2] * y[1], x[0] * y[2] - x[2] * y[0], x[0] * y[1] - x[1] * y[0]]

def dotProd(x, y):
	return [sum(list(map(lambda a, b: a * b, x, y)))]

def vector(x, y):
	return list(map(lambda a, b: b - a, x, y))
for _ in range(int(input().strip())):
	a = list(map(int, input().strip().split(' ')))
	b = list(map(int, input().strip().split(' ')))
	c = list(map(int, input().strip().split(' ')))
	d = list(map(int, input().strip().split(' ')))
	if dotProd(vector(a, d), crossProd(vector(a, b), vector(a, c))) == [0]:
		print('YES')
	else:
		print('NO')


import sys

def solve(pp):
	vv = []
	for (a, b) in zip(pp, pp[1:]):
		v = (a[0] - b[0], a[1] - b[1], a[2] - b[2])
		vv.append(v)
	(a, b) = vv[:2]
	(u1, u2, u3) = a
	(v1, v2, v3) = b
	axb = (u2 * v3 - u3 * v2, u3 * v1 - u1 * v3, u1 * v2 - u2 * v1)
	print('axb=%s' % list(axb), file=sys.stderr)
	c = vv[2]
	(u1, u2, u3) = axb
	(v1, v2, v3) = c
	axbdotc = u1 * v1 + u2 * v2 + u3 * v3
	print('axb.c=%s' % axbdotc, file=sys.stderr)
	return not axbdotc
t = int(input())
for _ in range(t):
	pp = []
	for _ in range(4):
		p = tuple(map(int, input().split()))
		pp.append(p)
	if solve(pp):
		print('YES')
	else:
		print('NO')