Chef is playing with weights. He has an object weighing W units. He also has three weights each of X, Y, and Z units respectively. Help him determine whether he can measure the exact weight of the object with one or more of these weights.

If it is possible to measure the weight of object with one or more of these weights, print YES, otherwise print NO. 

------ Input Format ------ 

- The first line of input will contain a single integer T, denoting the number of test cases.
- Each test case consists of single line containing a four positive integers W, X, Y, and Z.

------ Output Format ------ 

For each test case, output on a new line YES if it is possible to measure the weight of object with one or more of these weights, otherwise print NO.

You may print each character of the string in either uppercase or lowercase (for example, the strings yes, YES, Yes, and yeS will all be treated as identical).

------ Constraints ------ 

$1 ≤ T ≤ 10^{4}$
$1 ≤ W, X, Y, Z ≤ 10^{5}$

----- Sample Input 1 ------ 
4
5 2 1 6
7 9 7 2
20 8 10 12
20 10 11 12

----- Sample Output 1 ------ 
NO
YES
YES
NO

----- explanation 1 ------ 
Test Case $1$: It is not possible to measure $5$ units using any combination of given weights.

Test Case $2$: Chef can use the second weight of $7$ units to measure the object exactly.

Test Case $3$: Chef can use combination of first and third weights to measure $8+12=20$ units.

Test Case $4$: Chef cannot measure $20$ units of weight using any combination of given weights.

Difficulty: EASY
Tags: Mathematics

Starter code:

Solutions:
for _ in range(int(input())):
	(w, x, y, z) = map(int, input().split())
	if w == x or w == y or w == z:
		print('YES')
	elif x + y + z == w or x + y == w or y + z == w or (x + z == w):
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	(w, x, y, z) = map(int, input().split())
	if w == x or w == y or w == z or (w == x + y) or (w == y + z) or (w == z + x) or (w == x + y + z):
		print('YES')
	else:
		print('NO')
	t -= 1


t = int(input())
for i in range(t):
	(w, x, y, z) = map(int, input().split())
	if w == x or w == y or w == z or (w == x + y + z):
		print('YES')
	else:
		a1 = x + y
		a2 = y + z
		a3 = z + x
		if w == a1 or w == a2 or w == a3:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(W, X, Y, Z) = map(int, input().split())
	if W == X or W == Y or W == Z or (W == X + Y) or (W == Y + Z) or (W == Z + X) or (W == X + Y + Z):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(x, a, b, c) = map(int, input().split())
	a1 = a + b
	a2 = b + c
	a3 = c + a
	a4 = a + b + c
	if x == a1 or x == a2 or x == a3 or (x == a) or (x == b) or (x == c) or (x == a4):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b, c, d) = map(int, input().split())
	if a == b + c or a == b + d or a == c + d or (a == b) or (a == c) or (a == d) or (a == b + c + d):
		print('YES')
	else:
		print('NO')


for j in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	if a == b or a == c or a == d:
		print('YES')
	elif a == b + c or a == b + d or a == c + d or (a == b + c + d):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(0, t):
	(w, x, y, z) = map(int, input().split())
	if w == x + y or w == y + z or w == z + x or (w == x + y + z) or (w == x) or (w == y) or (w == z):
		print('YES')
	else:
		print('NO')


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


n = int(input())
for i in range(0, n):
	(W, X, Y, Z) = map(int, input().split())
	if W == X or W == Y or W == Z or (W == X + Y) or (W == Y + Z) or (W == Z + X) or (W == X + Y + Z):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(goal, x, y, z) = map(int, input().split())
	if x + y == goal or x + z == goal or y + z == goal or (x == goal) or (y == goal) or (z == goal) or (x + y + z == goal):
		print('YES')
	else:
		print('NO')


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


for i in range(int(input())):
	(W, X, Y, Z) = map(int, input().split())
	s1 = X + Y
	s2 = Y + Z
	s3 = X + Z
	s4 = X + Y + Z
	if W - s1 == 0 or W - s2 == 0 or W - s3 == 0 or (W - s4 == 0) or (W - X == 0) or (W - Y == 0) or (W - Z == 0):
		print('YES')
	else:
		print('NO')


def weigh(a, b, c, d):
	if a == b or a == c or a == d:
		return 'YES'
	elif a == b + c or a == d + c or a == b + d or (a == b + c + d):
		return 'YES'
	else:
		return 'NO'
t = int(input())
for i in range(0, t):
	(w, x, y, z) = map(int, input().split())
	res = weigh(w, x, y, z)
	print(res)


n = int(input())
for i in range(n):
	(m, a, b, c) = list(map(int, input().split()))
	if a == m or b == m or c == m or (a + b == m) or (b + c == m) or (c + a == m) or (a + b + c == m):
		print('YES')
	else:
		print('NO')


def wei(a, b, x, y):
	if b + y == a or x + y == a or b + x == a:
		return 'YES'
	elif b == a or x == a or y == a:
		return 'YES'
	elif a == b + x + y:
		return 'YES'
	else:
		return 'NO'
t = int(input())
for i in range(t):
	(a, b, x, y) = map(int, input().split())
	v = wei(a, b, x, y)
	print(v)