Chef likes problems which using some math. Now he asks you to solve next one. You have 4 integers, Chef wondering is there non-empty subset which has sum equals 0.

-----Input-----
The first line of input contains T - number of test cases. 
Each of the next T lines containing four pairwise distinct integer numbers - a, b, c, d.

-----Output-----
For each test case output "Yes", if possible to get 0 by choosing non-empty subset of {a, b, c, d} with sum equal 0, or "No" in another case.

-----Constraints-----
- 1 ≤ T ≤ 103
- -106 ≤ a, b, c, d ≤ 106 

-----Example-----
Input:
3
1 2 0 3
1 2 4 -1
1 2 3 4

Output:
Yes
Yes
No

-----Explanation-----
Example case 1. We can choose subset {0} 
Example case 2. We can choose subset {-1, 1}

Source: codechef | Difficulty: EASY
Tags: Bit manipulation

Mathematics

Complete search


Solutions:
t = int(input())
while t != 0:
	l = list(map(int, input().split()))
	if 0 in l:
		print('Yes')
	elif sum(l) == 0:
		print('Yes')
	elif l[0] + l[1] == 0 or l[1] + l[2] == 0 or l[2] + l[3] == 0 or (l[0] + l[2] == 0) or (l[0] + l[3] == 0) or (l[1] + l[3] == 0) or (l[0] + l[1] + l[2] == 0) or (l[1] + l[2] + l[3] == 0) or (l[0] + l[1] + l[3] == 0) or (l[0] + l[3] + l[2] == 0):
		print('Yes')
	else:
		print('No')
	t -= 1


for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	l = [a, b, c, d, a + b, a + c, a + d, b + c, b + d, c + d, a + b + c, a + b + d, a + c + d, b + c + d, a + b + c + d]
	if 0 in l:
		print('Yes')
	else:
		print('No')


import itertools

def has_sum_zero(nums):
	for i in range(1, len(nums) + 1):
		subsets = itertools.combinations(nums, i)
		for subset in subsets:
			if sum(subset) == 0:
				return 'Yes'
	return 'No'
T = int(input())
for i in range(T):
	(a, b, c, d) = map(int, input().split())
	print(has_sum_zero([a, b, c, d]))


from itertools import combinations
t = int(input())
for _ in range(t):
	l = list(map(int, input().split(' ')))
	if 0 in l or sum(l) == 0:
		print('Yes')
	else:
		choose = False
		possibilities = list(list(combinations(l, 3)) + list(combinations(l, 2)))
		for _ in possibilities:
			if sum(_) == 0:
				choose = True
				break
		if choose:
			print('Yes')
		else:
			print('No')


def solveQuestion():
	l = list(map(int, input().split()))
	if 0 in l:
		return 'Yes'
	elif sum(l) == 0:
		return 'Yes'
	elif l[0] + l[1] == 0 or l[0] + l[2] == 0 or l[0] + l[3] == 0 or (l[1] + l[2] == 0) or (l[1] + l[3] == 0) or (l[2] + l[3] == 0) or (l[0] + l[2] + l[3] == 0) or (l[0] + l[1] + l[3] == 0) or (l[1] + l[2] + l[3] == 0) or (l[0] + l[1] + l[2] == 0):
		return 'Yes'
	else:
		return 'No'
for _ in range(int(input())):
	print(solveQuestion())


def sumOfSubsetIsZero():
	l = list(map(int, input().split(' ')))
	op = [[]]
	for i in l:
		op += [lst + [i] for lst in op]
		for i in range(1, len(op)):
			if sum(op[i]) == 0:
				return 'Yes'
	return 'No'
t = int(input())
while t:
	print(sumOfSubsetIsZero())
	t -= 1


def subset(n, s, l):
	for i in range(1, 2 ** n):
		temp = 0
		for j in range(n):
			if i & 1 << j:
				temp += l[j]
		if temp == s:
			return True
	return False
for _ in range(int(input())):
	l = list(map(int, input().split()))
	print('Yes' if subset(len(l), 0, l) else 'No')


import itertools

def all_options(l):
	res = []
	for n in range(len(l)):
		temp = list(itertools.permutations(l, n + 1))
		for item in temp:
			res += [sum(item)]
	return res
for _ in range(int(input())):
	l = list(map(int, input().split()))
	ans = 'Yes'
	if not 0 in l:
		ans = 'No'
		negs = [x for x in l if x < 0]
		if not len(negs) in [0, 4]:
			poss = [x for x in l if x > 0]
			neg_ops = all_options(negs)
			pos_ops = all_options(poss)
			for op in neg_ops:
				if -op in pos_ops:
					ans = 'Yes'
					break
	print(ans)


for i in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	m = (a, b, c, d, a + b, a + c, a + d, b + c, b + d, c + d, a + b + c, a + b + d, b + c + d, c + a + d, a + b + c + d)
	if 0 in m:
		print('Yes')
	else:
		print('No')


for i in range(int(input())):
	n = list(map(int, input().split()))
	if 0 in n:
		print('Yes')
	else:
		a = n[0]
		b = n[1]
		c = n[2]
		d = n[3]
		if sum(n) == 0 or a + b + c == 0 or a + c + d == 0 or (a + d + b == 0) or (c + b + d == 0) or (a + b == 0) or (a + c == 0) or (a + d == 0) or (b + c == 0) or (b + d == 0) or (c + d == 0):
			print('Yes')
		else:
			print('No')


for _ in range(int(input())):
	a = list(map(int, input().split()))
	c = 0
	for i in range(1, 16):
		s = 0
		for j in range(4):
			if i & 1 << j:
				s += a[j]
		if s == 0:
			c = 1
			print('Yes')
			break
	if c == 0:
		print('No')


for _ in range(int(input())):
	arr = sorted(list(map(int, input().split())))
	(a, b, c, d) = (arr[0], arr[1], arr[2], arr[3])
	if 0 in arr:
		print('Yes')
	elif (a + b and a + c and a + d and b + c and b + d and c + d and a + b + c and (a + b + d) and (a + c + d) and (b + c + d) and (a + b + c + d)) == 0:
		print('Yes')
	else:
		print('No')


import itertools
for i in range(int(input())):
	l = [int(x) for x in input().split()]
	if 0 in l:
		print('Yes')
	elif sum(l) == 0:
		print('Yes')
	else:
		flag = 0
		for j in l:
			if -j in l:
				print('Yes')
				flag = 1
				break
		if flag == 0:
			for s in itertools.combinations(l, 3):
				if sum(s) == 0:
					print('Yes')
					flag = 1
					break
		if flag == 0:
			print('No')


import itertools
t = int(input())
while t:
	nums = list(map(int, input().split()))
	if 0 in nums:
		print('Yes')
	else:
		lst = []
		n = 1
		while n <= 4:
			lst.extend(list(itertools.combinations(nums, n)))
			n += 1
		a = 0
		for row in lst:
			if sum(list(row)) == 0:
				a = 1
				break
		if a == 1:
			print('Yes')
		else:
			print('No')
	t -= 1


for _ in range(int(input())):
	a = [int(x) for x in input().split()]
	n = 4
	tot = 1 << n
	flag = False
	for mask in range(tot):
		s = []
		for i in range(n):
			f = 1 << i
			if mask & f != 0:
				s.append(a[i])
		if len(s) != 0 and sum(s) == 0:
			flag = True
			break
	if flag:
		print('Yes')
	else:
		print('No')


import os, sys, io, math
from re import *
from math import *
from array import *
from heapq import *
from bisect import *
from functools import *
from itertools import *
from statistics import *
from collections import *
I = lambda : [*map(int, sys.stdin.readline().split())]
IP = lambda : map(int, input().split())
IS = lambda : input()
IN = lambda : int(input())
IF = lambda : float(input())

def f():
	l = I()
	x = 1
	if 0 in l:
		return 'Yes'
	elif sum(l) == 0:
		return 'Yes'
	elif l[0] + l[1] == 0 or l[0] + l[1] + l[2] == 0 or l[0] + l[2] + l[3] == 0 or (l[0] + l[1] + l[3] == 0) or (l[0] + l[2] == 0) or (l[0] + l[3] == 0):
		return 'Yes'
	elif l[1] + l[2] == 0 or l[1] + l[2] + l[3] == 0 or l[1] + l[3] == 0:
		return 'Yes'
	elif l[2] + l[3] == 0:
		return 'Yes'
	else:
		return 'No'
for _ in range(IN()):
	print(f())


a = int(input(''))
for i in range(a):
	(a, b, c, d) = [int(x) for x in input('').split()]
	if a + b == 0 or a + c == 0 or a + d == 0 or (b + c == 0) or (b + d == 0) or (c + d == 0):
		print('Yes')
	elif a + b + c == 0 or a + b + d == 0 or a + c + d == 0 or (b + c + d == 0):
		print('Yes')
	elif a == 0 or b == 0 or c == 0 or (d == 0):
		print('Yes')
	elif a + b + c + d == 0:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	(a, b, c, d) = list(map(int, input().split()))
	flag = 0
	if a == 0 or b == 0 or c == 0 or (d == 0):
		print('Yes')
		flag = 1
	l = [a, b, c, d]
	if flag == 0:
		for i in range(len(l)):
			for j in range(i + 1, len(l)):
				if l[i] + l[j] == 0:
					print('Yes')
					flag = 1
					break
	if flag == 0:
		if a + c + d == 0 or b + c + d == 0 or a + b + c == 0 or (a + b + d == 0):
			flag = 1
			print('Yes')
	if flag == 0:
		if a + b + c + d == 0:
			print('Yes')
			flag = 1
	if flag == 0:
		print('No')


import itertools

def findsubsets(s, n):
	return [set(i) for i in itertools.combinations(s, n)]
for a in range(int(input())):
	elements = set(map(int, input().split()))
	check = False
	for i in range(1, 5, 1):
		array = findsubsets(elements, i)
		for i in array:
			if sum(i) == 0:
				check = True
				break
		if check:
			break
	if check:
		print('Yes')
	else:
		print('No')


def subset(a, b, c, d):
	if a == 0 or b == 0 or c == 0 or (d == 0):
		return True
	if a + b == 0 or a + c == 0 or a + d == 0 or (b + c == 0) or (b + d == 0) or (c + d == 0):
		return True
	if a + b + c == 0 or a + b + d == 0 or a + c + d == 0 or (b + c + d == 0):
		return True
	if a + b + c + d == 0:
		return True
	return False
for i in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	if subset(a, b, c, d):
		print('Yes')
	else:
		print('No')


t = int(input())
while t:
	t -= 1
	c = 0
	ar = [int(i) for i in input().strip().split()]
	for i in range(1, 16):
		b = bin(i)[2:].zfill(4)
		s = 0
		for i in range(4):
			if b[i] == '1':
				s += ar[i]
		if s == 0:
			c = 1
			break
	print('Yes' if c == 1 else 'No')


import itertools
tc = int(input())
for _ in range(tc):
	x = set(map(int, input().split()))
	subsets = []
	for r in range(1, len(x) + 1):
		for subset in itertools.combinations(x, r):
			subsets.append(subset)
	sums = []
	for i in subsets:
		sums.append(sum(i))
	if 0 in sums:
		print('Yes')
	else:
		print('No')


t = int(input())
for tc in range(t):
	(a, b, c, d) = map(int, input().split())
	if a == 0 or b == 0 or c == 0 or (d == 0) or (abs(a + b) == 0) or (abs(a + c) == 0) or (abs(a + d) == 0) or (abs(b + c) == 0) or (abs(b + d) == 0) or (abs(c + d) == 0) or (abs(a + b + c) == 0) or (abs(a + b + d) == 0) or (abs(a + c + d) == 0) or (abs(b + c + d) == 0) or (abs(a + b + c + d) == 0):
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	arr = list(map(int, input().strip().split()))
	flag = 1
	for p in range(1, 16):
		sum = 0
		for i in range(0, 4):
			f = 1 << i
			if p & f != 0:
				sum += arr[i]
		if sum == 0:
			flag = 0
			print('Yes')
	if flag == 1:
		print('No')


for h in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	if a + b + c + d == 0 or a + b + c == 0 or a + b == 0 or (a == 0):
		print('Yes')
	elif b == 0 or c == 0 or d == 0 or (a + c == 0) or (a + d == 0) or (a + b + d == 0):
		print('Yes')
	elif a + c + d == 0 or b + c + d == 0 or b + c == 0 or (b + d == 0) or (c + d == 0):
		print('Yes')
	else:
		print('No')


t = int(input())
while t:
	a = [int(x) for x in input().split()]
	tot = 1 << 4
	flag = 0
	for i in range(1, tot):
		sum = 0
		for j in range(4):
			f = 1 << j
			if f & i:
				sum += a[j]
		if sum == 0:
			flag = 1
			break
	print('Yes' if sum == 0 else 'No')
	t -= 1


t = int(input())
for i in range(t):
	a = list(map(int, input().split()))
	ans = 'No'
	pos_count = 0
	neg_count = 0
	a.sort()
	if 0 in a:
		ans = 'Yes'
	elif sum(a) == 0:
		ans = 'Yes'
	elif 0 not in a:
		for j in range(len(a)):
			if a[j] < 0:
				neg_count += 1
			else:
				pos_count += 1
		for j in range(neg_count):
			abs_a = abs(a[j])
			if abs_a in a:
				ans = 'Yes'
				break
			else:
				for j in range(len(a)):
					if sum(a) - a[j] == 0:
						ans = 'Yes'
						break
	print(ans)


from collections import defaultdict as dd
from collections import deque
import bisect
import heapq
import sys
input = sys.stdin.readline

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))
t = ri()
for _ in range(t):
	aa = rl()
	n = len(aa)
	answer = 'No'
	for mask in range(1, 2 ** n):
		sum = 0
		for k in range(n):
			if mask & 1 << k:
				sum += aa[k]
		if sum == 0:
			answer = 'Yes'
			break
	print(answer)


t = int(input())
for _ in range(t):
	(a, b, c, d) = list(map(int, input().split()))
	if a + b + c + d == 0:
		print('Yes')
	elif a + b + c == 0 or a + b + d == 0 or b + c + d == 0 or (a + c + d == 0):
		print('Yes')
	elif a + b == 0 or a + c == 0 or a + d == 0 or (b + c == 0) or (b + d == 0) or (c + d == 0):
		print('Yes')
	elif a == 0 or b == 0 or c == 0 or (d == 0):
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	l = list(map(int, input().split()))
	flag = 0
	if sum(l) == 0:
		flag = 1
	else:
		for i in range(len(l)):
			if l[i] == 0:
				flag = 1
				break
		if flag == 0:
			for i in range(len(l) - 1):
				s = 0
				for j in range(i + 1, len(l)):
					s = l[i] + l[j]
					if s == 0:
						flag = 1
						break
			for i in range(len(l) - 2):
				s = 0
				for j in range(i + 1, len(l) - 1):
					for k in range(i + 2, len(l)):
						s = l[i] + l[j] + l[k]
						if s == 0:
							flag = 1
							break
	if flag == 1:
		print('Yes')
	else:
		print('No')


import itertools

def ans(n):
	for i in range(1, len(n) + 1):
		s = itertools.combinations(n, i)
		for i in s:
			if sum(i) == 0:
				return 'Yes'
	return 'No'
for i in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	print(ans([a, b, c, d]))


for _ in range(int(input())):
	(a, b, c, d) = [int(x) for x in input().split()]
	ls = [a, b, c, d]
	f = 0
	for i in range(2 ** 4):
		s = 0
		arr = []
		for j in range(4):
			if i & 1 << j > 0:
				s += ls[j]
				arr.append(ls[j])
		if s == 0 and len(arr) > 0:
			print('Yes')
			f = 1
			break
	if f == 0:
		print('No')


def check_sub(a, b, c, d):
	if 0 in [a, b, c, d]:
		return 1
	elif a + b + c + d == 0:
		return 1
	elif a + b + c == 0 or a + b + d == 0 or a + c + d == 0 or (b + c + d == 0):
		return 1
	elif a + b == 0 or a + c == 0 or a + d == 0 or (b + c == 0) or (b + d == 0) or (c + d == 0):
		return 1
	else:
		return 0
for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	res = check_sub(a, b, c, d)
	if res:
		print('Yes')
	else:
		print('No')


from collections import Counter
t = int(input())
for _ in range(t):
	l = list(map(int, input().split()))
	if 0 in l:
		print('Yes')
	elif sum(l) == 0:
		print('Yes')
	elif l[0] + l[1] == 0 or l[0] + l[1] + l[2] == 0 or l[0] + l[2] + l[3] == 0 or (l[0] + l[1] + l[3] == 0) or (l[0] + l[2] == 0) or (l[0] + l[3] == 0):
		print('Yes')
	elif l[1] + l[2] == 0 or l[1] + l[2] + l[3] == 0 or l[1] + l[3] == 0:
		print('Yes')
	elif l[2] + l[3] == 0:
		print('Yes')
	else:
		print('No')


from itertools import combinations
for _ in range(int(input())):
	l = list(map(int, input().split()))
	c = 0
	for i in range(1, 5):
		if c:
			break
		a = list(combinations(l, i))
		for j in a:
			if sum(j) == 0:
				c = 1
				break
	if c:
		print('Yes')
	else:
		print('No')


T = int(input())
for tc in range(T):
	arr = list(map(int, input().split(' ')))
	if sum(arr) == 0:
		print('Yes')
	elif 0 in arr:
		print('Yes')
	elif arr[0] + arr[1] + arr[2] == 0 or arr[0] + arr[2] + arr[3] == 0 or arr[0] + arr[1] + arr[3] == 0 or (arr[1] + arr[2] + arr[3] == 0):
		print('Yes')
	elif arr[0] + arr[1] == 0 or arr[0] + arr[2] == 0 or arr[0] + arr[3] == 0 or (arr[1] + arr[2] == 0) or (arr[1] + arr[3] == 0) or (arr[2] + arr[3] == 0):
		print('Yes')
	else:
		print('No')


def sumZero(A):
	if 0 in A or sum(A) == 0:
		return 'Yes'
	elif sum(A) in A:
		return 'Yes'
	else:
		for i in range(4):
			for j in range(4):
				if A[i] + A[j] == 0:
					return 'Yes'
		return 'No'
for _ in range(int(input())):
	A = [int(i) for i in input().split()]
	print(sumZero(A))


from itertools import combinations
t = int(input())
for _ in range(t):
	numbers = list(map(int, input().split()))
	done = False
	for i in range(1, len(numbers) + 1):
		if done:
			break
		for comb in combinations(numbers, i):
			if sum(comb) == 0:
				print('Yes')
				done = True
				break
	if not done:
		print('No')


import itertools
for tc in range(int(input())):
	flag = 0
	n = list(map(int, input().split()))
	ones = list(itertools.combinations(n, 1))
	twos = list(itertools.combinations(n, 2))
	threes = list(itertools.combinations(n, 3))
	for c in ones:
		if sum(c) == 0:
			flag = 1
	for c in twos:
		if sum(c) == 0:
			flag = 1
	for c in threes:
		if sum(c) == 0:
			flag = 1
	if sum(n) == 0:
		flag = 1
	if flag == 1:
		print('Yes')
	else:
		print('No')


t = int(input())
tr = []
for mm in range(0, t):
	up = str(input())
	kl = up.split(' ')
	tvc = []
	for mm in kl:
		tvc.append(int(mm))
	tr.append(tvc)
for nn in tr:
	ip = list(nn)
	ip.sort()
	if ip[0] > 0:
		print('No')
	elif 0 in ip:
		print('Yes')
	else:
		po = 0
		for kk in ip:
			if kk < 0:
				if kk * -1 in ip:
					po = 1
					print('Yes')
					break
			else:
				break
		if po == 0:
			upt = 0
			for vvc in ip:
				upt += vvc
			if upt == 0:
				print('Yes')
			else:
				ptfc = 0
				kd = 'No'
				for vvx in range(0, len(ip)):
					ptfc += ip[vvx]
					gmty = 0
					for gg in range(0, len(ip)):
						if gg != vvx:
							ptfc += ip[gg]
							ltrop = 0
							for thyu in range(0, len(ip)):
								if thyu != gg and thyu != vvx:
									ptfc += ip[thyu]
									if ptfc == 0:
										ltrop = 1
										break
									else:
										ptfc -= ip[thyu]
							if ltrop == 1:
								gmty = 1
								break
							else:
								ptfc -= ip[gg]
					if gmty == 1:
						kd = 'Yes'
						break
					else:
						ptfc -= ip[vvx]
				print(kd)


t = int(input())
for ni in range(t):
	l = list(map(int, input().split()))
	(a, b, c, d) = (l[0], l[1], l[2], l[3])
	if 0 in l or sum(l) == 0:
		print('Yes')
	elif a + b == 0 or a + c == 0 or a + d == 0 or (b + c == 0) or (b + d == 0) or (c + d == 0) or (a + b + c == 0) or (a + b + d == 0) or (a + c + d == 0) or (b + c + d == 0):
		print('Yes')
	else:
		print('No')


def ss(a, su, i, cnt):
	if su == 0 and cnt != 0:
		return 1
	if i < 0:
		return 0
	return ss(a, su + a[i], i - 1, cnt + 1) + ss(a, su, i - 1, cnt)
for _ in range(int(input())):
	a = [int(x) for x in input().split()]
	if ss(a, 0, 3, 0):
		print('Yes')
	else:
		print('No')


t = int(input())
for _ in range(t):
	ar = list(map(int, input().split()))
	ok = False
	for i in range(1, 16):
		csum = 0
		for j in range(len(ar)):
			if i & 1 << j > 0:
				csum += ar[j]
		if csum == 0:
			ok = True
			break
	if ok:
		print('Yes')
	else:
		print('No')


t = int(input())
for i in range(t):
	a = list(map(int, input().split()))
	b = []
	c = []
	k = 0
	for j in a:
		if j == 0:
			k = 1
			break
	if k == 1:
		print('Yes')
	elif a[0] + a[1] == 0 or a[0] + a[2] == 0 or a[0] + a[3] == 0 or (a[1] + a[2] == 0) or (a[1] + a[3] == 0) or (a[2] + a[3] == 0) or (a[0] + a[1] + a[2] == 0) or (a[0] + a[1] + a[3] == 0) or (a[0] + a[2] + a[3] == 0) or (a[1] + a[2] + a[3] == 0) or (a[0] + a[1] + a[2] + a[3] == 0):
		print('Yes')
	else:
		print('No')


import itertools

def permutation_with_replacement(iterable, r=None):
	r = len(iterable) if r is None else r
	return list(itertools.product(*[iterable] * r))
for _ in range(int(input())):
	a = [int(x) for x in input().split()]
	ans = 'No'
	b = permutation_with_replacement([0, 1], 4)
	for i in b[1:]:
		cur = 0
		for j in range(4):
			cur += i[j] * a[j]
		if cur == 0:
			ans = 'Yes'
			break
	print(ans)


from itertools import permutations

def check_0(arr):
	if sum(arr) == 0:
		return 'Yes'
	arr_len = len(arr)
	for perm in permutations(arr):
		for j in range(1, arr_len):
			if sum(perm[:j]) == 0:
				return 'Yes'
	return 'No'
for i in range(int(input())):
	arr = [int(x) for x in input().split()]
	print(check_0(arr))


def solution(a):
	if 0 in a or sum(a) == 0:
		print('Yes')
		return None
	for i in a:
		if i <= 0:
			break
	else:
		print('No')
		return None
	if a[0] + a[1] + a[2] == 0 or a[0] + a[1] + a[3] == 0 or a[0] + a[2] + a[3] == 0 or (a[1] + a[2] + a[3] == 0):
		print('Yes')
		return None
	elif a[0] + a[1] == 0 or a[0] + a[2] == 0 or a[0] + a[3] == 0 or (a[1] + a[2] == 0) or (a[1] + a[3] == 0) or (a[2] + a[3] == 0):
		print('Yes')
		return None
	else:
		print('No')
	return None
for _ in range(int(input())):
	a = list(map(int, input().split()))
	solution(a)


for _ in range(int(input())):
	a = list(map(int, input().split()))
	test = 0
	n = 4
	for mask in range(1, 1 << n):
		s = 0
		for i in range(n):
			if mask & 1 << i:
				s += a[i]
		if s == 0:
			test = 1
			print('Yes')
			break
	if not test:
		print('No')


def main():
	for _ in range(int(input())):
		A = list(map(int, input().split(' ')))[:4]
		if 0 in A:
			print('Yes')
		elif sum(A) == 0:
			print('Yes')
		elif A[0] == 0 or A[1] == 0 or A[2] == 0 or (A[3] == 0) or (A[0] + A[1] == 0) or (A[0] + A[2] == 0) or (A[0] + A[3] == 0) or (A[0] + A[1] + A[2] == 0) or (A[0] + A[2] + A[3] == 0) or (A[0] + A[1] + A[3] == 0) or (A[1] + A[2] + A[3] == 0) or (A[1] + A[2] == 0) or (A[1] + A[3] == 0) or (A[2] + A[3] == 0) or (A[0] + A[2] + A[3] == 0):
			print('Yes')
		else:
			print('No')
main()


for _ in range(int(input())):
	a = list(map(int, input().split()))
	n = 4
	test = 0
	for mask in range(1, 1 << n):
		s = set()
		for i in range(n):
			f = 1 << i
			if mask & f != 0:
				s.add(a[i])
		if sum(s) == 0:
			test = 1
			break
	if test:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	A = list(map(int, input().split(' ')))[:4]
	if A[0] == 0 or A[1] == 0 or A[2] == 0 or (A[3] == 0) or (A[0] + A[1] == 0) or (A[0] + A[2] == 0) or (A[0] + A[3] == 0) or (A[0] + A[1] + A[2] == 0) or (A[0] + A[2] + A[3] == 0) or (A[0] + A[1] + A[3] == 0) or (A[1] + A[2] + A[3] == 0) or (A[1] + A[2] == 0) or (A[1] + A[3] == 0) or (A[2] + A[3] == 0) or (A[0] + A[2] + A[3] == 0) or (A[0] + A[1] + A[2] + A[3] == 0):
		print('Yes')
	else:
		print('No')


def sol(i, s):
	if i == 4:
		x.append(s)
		return
	sol(i + 1, s)
	sol(i + 1, s + l[i])
for _ in range(int(input())):
	x = []
	l = list(map(int, input().split()))
	sol(0, 0)
	flg = False
	if l.count(0) > 1:
		print('Yes')
	else:
		for i in range(16):
			for j in range(16):
				if i != j and x[i] + x[j] == 0:
					print('Yes')
					flg = True
					break
			if flg:
				break
		else:
			print('No')


from itertools import combinations
for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	lst = []
	for i in range(1, 5):
		all_comb = combinations([a, b, c, d], i)
		for comb in all_comb:
			lst.append(list(comb))
	for comb in lst:
		if sum(comb) == 0:
			print('Yes')
			break
	else:
		print('No')


t = int(input())
for x in range(t):
	m = 0
	l = [int(i) for i in input().split()]
	for i in range(0, 1 << 4):
		ans = 0
		for j in range(0, 4):
			f = 1 << j
			if i & f != 0:
				ans = ans + l[j]
				if ans == 0:
					m = 1
					print('Yes')
					break
		if m == 1:
			break
	else:
		print('No')


t = int(input())
POW = 1 << 4
for _ in range(t):
	nums = list(map(int, input().split(' ')))
	f = 1
	for k in range(POW):
		s = -1
		for (i, j) in enumerate(nums):
			f = 1 << i
			if f & k != 0:
				if s == -1:
					s = 0
				s += j
		if s == 0:
			f = 0
			break
	print(['No', 'Yes'][f == 0])


t = int(input())
for _ in range(t):
	l = list(map(int, input().split(' ')))
	flag = False
	tot = 1 << len(l)
	for i in range(tot):
		sum = 0
		c = 0
		for j in range(len(l)):
			k = 1 << j
			if i & k != 0:
				sum = sum + l[j]
				c = c + 1
		if sum == 0 and c != 0:
			print('Yes')
			flag = True
			break
	if flag == False:
		print('No')


for i in range(int(input())):
	l = list(map(int, input().split()))
	if 0 in l:
		print('Yes')
	elif l[0] + l[1] == 0 or l[0] + l[2] == 0 or l[0] + l[3] == 0 or (l[1] + l[2] == 0) or (l[2] + l[3] == 0) or (l[1] + l[3] == 0):
		print('Yes')
	elif l[0] + l[1] + l[2] == 0 or l[0] + l[2] + l[3] == 0 or l[1] + l[2] + l[3] == 0 or (l[0] + l[1] + l[3] == 0):
		print('Yes')
	elif sum(l) == 0:
		print('Yes')
	else:
		print('No')