Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well.

You are given the sizes of angles of a simple quadrilateral (in degrees) $A$, $B$, $C$ and $D$, in some order along its perimeter. Determine whether the quadrilateral is cyclic.

Note: A quadrilateral is cyclic if and only if the sum of opposite angles is $180^{\circ}$.

------  Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains four space-separated integers $A$, $B$, $C$ and $D$.

------  Output ------
Print a single line containing the string "YES" if the given quadrilateral is cyclic or "NO" if it is not (without quotes).

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

------  Constraints ------
$1 ≤ T ≤ 10^{4}$
$1 ≤ A, B, C, D ≤ 357$
$A + B + C + D = 360$

----- Sample Input 1 ------ 
3
10 20 30 300
10 20 170 160
179 1 179 1
----- Sample Output 1 ------ 
NO
YES
NO
----- explanation 1 ------ 
Example case 1: The sum of two opposite angles $A + C = 10^{\circ} + 30^{\circ} \neq 180^{\circ}$.

Example case 2: The sum of two opposite angles $A + C = 10^{\circ} + 170^{\circ} = 180^{\circ}$ and $B + D = 20^{\circ} + 160^{\circ} = 180^{\circ}$.

Example case 3: The sum of two opposite angles $B + D = 1^{\circ} + 1^{\circ} \neq 180^{\circ}$.

Difficulty: EASY
Tags: Implementation

Starter code:

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


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


n = int(input())
for i in range(n):
	(A, B, C, D) = tuple(map(int, input().split()))
	if A + C == 180 and B + D == 180:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	n = len(l)
	for i in range(n - 2):
		if l[i] + l[i + 2] == 180:
			print('YES')
			break
		else:
			print('NO')
			break


for i in range(int(input())):
	x = list(map(int, input().split()))
	a = x[0]
	b = x[1]
	c = x[2]
	d = x[3]
	if a + c == 180 and b + d == 180:
		print('YES')
	else:
		print('NO')


T = int(input())
for i in range(T):
	(a, b, c, d) = map(int, input().split())
	x = a + c
	y = b + d
	if x == 180 and y == 180:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	a = list(map(int, input().split(' ')))
	if a[0] + a[2] == 180 and a[1] + a[3] == 180:
		print('YES')
	else:
		print('NO')


t = int(input())
while t != 0:
	t -= 1
	(a, b, c, d) = map(int, input().split())
	if a + c == b + d == 180:
		print('YES')
	else:
		print('NO')


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


t = int(input())
for i in range(t):
	(m, n, o, p) = map(int, input().split())
	if m + o and n + p == 180:
		print('YES')
	else:
		print('NO')


T = int(input())
for test in range(T):
	(A, B, C, D) = map(int, input().split())
	S = 180
	if A + C != 180 and B + D != 180:
		print('NO')
	else:
		print('YES')


def cyclic(a, b, c, d):
	if a + c == 180:
		return 'YES'
	elif b + d == 180:
		return 'YES'
	else:
		return 'NO'
t = int(input())
for i in range(t):
	(a, b, c, d) = map(int, input().split())
	v = cyclic(a, b, c, d)
	print(v)


T = int(input())
for i in range(T):
	(A, B, C, D) = map(int, input().split())
	k = A + C
	p = B + D
	if k == 180 or p == 180:
		print('YES')
	else:
		print('NO')


T = int(input())
for _ in range(T):
	(A, B, C, D) = map(int, input().split())
	if A + C == B + D == 180:
		print('YES')
	else:
		print('NO')