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

Chef has X coins worth 1 rupee each and Y coins worth 2 rupees each. He wants to distribute all of these X+Y coins to his two sons so that the total value of coins received by each of them is the same. Find out whether Chef will be able to do so.

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

- The first line of input contains a single integer T, denoting the number of testcases. The description of T test cases follows.
- Each test case consists of a single line of input containing two space-separated integers X and Y.

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

For each test case, print "YES" (without quotes) if Chef can distribute all the coins equally and "NO" otherwise. 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^{3}$
$0 ≤ X, Y ≤ 10^{8}$
$ X + Y > 0$

------ subtasks ------ 

Subtask 1 (100 points): Original constraints

----- Sample Input 1 ------ 
4
2 2
1 3
4 0
1 10

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

----- explanation 1 ------ 
Test case $1$: Chef gives each of his sons $1$ coin worth one rupee and $1$ coin worth two rupees.

Test case $3$: Chef gives each of his sons $2$ coins worth one rupee.

Source: codechef | Difficulty: EASY
Tags: Constructive algorithms

Mathematics

Ad-hoc


Solutions:
for _ in range(int(input())):
	(X, Y) = map(int, input().split())
	if X % 2 == 1:
		print('NO')
	elif Y % 2 == 1 and X == 0:
		print('NO')
	else:
		print('YES')


t = int(input())
for bunny in range(t):
	(x, y) = map(int, input().split())
	l = x * 1 + y * 2
	if x % 2 == 1:
		print('NO')
	elif y % 2 == 1 and x == 0:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(o, t) = map(int, input().split())
	if o == 0 and t % 2 != 0:
		print('NO')
	elif o % 2 != 0:
		print('NO')
	else:
		print('YES')


t = int(input())
while t > 0:
	t = t - 1
	(a, b) = map(int, input().split())
	if (a + b * 2) % 2 != 0 or (b % 2 != 0 and a < 2):
		print('NO')
	else:
		print('YES')


for k in range(int(input())):
	(x, y) = map(int, input().split())
	if x == 0 and y % 2 != 0:
		print('NO')
	elif (x + 2 * y) % 2 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n1, n2) = map(int, input().split())
	if n1 == 0:
		if n2 % 2 == 1:
			print('NO')
			continue
	if n1 % 2:
		print('NO')
	else:
		print('YES')


for i in range(int(input())):
	(x, y) = map(int, input().split())
	z = x + y * 2
	if z % 2 != 0 or (y % 2 != 0 and x < 2):
		print('NO')
	else:
		print('YES')


t = int(input())
while t > 0:
	x = input()
	(x, y) = x.split(' ')
	x = int(x)
	y = int(y)
	if (x + y * 2) % 2 != 0 or (x < 2 and y % 2 != 0):
		print('NO')
	else:
		print('YES')
	t -= 1


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a % 2 == 0 and (a > 0 or b % 2 == 0):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	if x % 2 == 1 or (x == 0 and y % 2 == 1):
		print('NO')
	else:
		print('YES')


for i in range(int(input())):
	(oc, tc) = map(int, input().split())
	print('YES' if oc % 2 == 0 and tc % 2 == 0 or (oc % 2 == 0 and tc % 2 != 0 and (oc > 0)) else 'NO')


for i in range(int(input())):
	I = list(map(int, input().split()))
	x = I[0]
	y = I[1]
	if x % 2 == 0 and y % 2 == 0:
		print('YES')
	elif x % 2 == 0 and x > 0 and (y % 2 == 1):
		print('YES')
	else:
		print('NO')


T = int(input())
while T > 0:
	(x, y) = map(int, input().split())
	if x == 0 and y % 2 == 0:
		print('YES')
	elif x == 0 and y % 2 != 0:
		print('NO')
	elif (x + 2 * y) % 2 == 0:
		print('YES')
	else:
		print('NO')
	T = T - 1


th = int(input())
yh = []
for mml in range(0, th):
	pp = str(input())
	ool = pp.split(' ')
	ir = []
	for ffg in ool:
		ir.append(int(ffg))
	yh.append(ir)
for mm in yh:
	uml = mm[0] + mm[1] * 2
	if uml % 2 == 0:
		otr = uml // 2
		if otr % 2 == 0:
			if otr // 2 <= mm[1]:
				print('YES')
			else:
				umth = otr - mm[1] * 2
				if umth <= mm[0]:
					print('YES')
				else:
					print('NO')
		else:
			yml = otr // 2
			if yml <= mm[1]:
				o = otr - yml * 2
				if o <= mm[0]:
					print('YES')
				else:
					print('NO')
			else:
				umth = otr - mm[1] * 2
				if umth <= mm[0]:
					print('YES')
				else:
					print('NO')
	else:
		print('NO')


T = int(input())
while T > 0:
	(a, b) = map(int, input().split())
	if a == 0 and b % 2 == 0:
		print('YES')
	elif a == 0 and b % 2 != 0:
		print('NO')
	elif (a + 2 * b) % 2 == 0:
		print('YES')
	else:
		print('NO')
	T = T - 1


n = int(input())
for i in range(n):
	(x, y) = [int(j) for j in input().split()]
	if x == 0 and y % 2 != 0:
		print('NO')
	elif x == 0 and y % 2 == 0:
		print('YES')
	elif (x + y * 2) % 2 != 0:
		print('NO')
	else:
		print('YES')


def solve(a, b):
	if a % 2 or (not a and b % 2):
		return 'NO'
	return 'YES'
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	print(solve(a, b))


def main():
	T = int(input())
	for _ in range(T):
		(x, y) = map(int, input().split(' '))
		print('NO' if (x + 2 * y) % 2 or (y % 2 and x < 2) else 'YES')
main()


T = int(input())
for t in range(T):
	(x, y) = map(int, input().split())
	y = y % 2
	x -= y * 2
	if x < 0:
		print('NO')
	elif x % 2 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	if abs(x - 2 * y) % 2 == 0 and x > 0:
		print('YES')
	elif abs(x - 2 * y) % 2 == 0 and y % 2 == 0:
		print('YES')
	else:
		print('NO')


T = int(input())
for cases in range(T):
	(X, Y) = [int(f) for f in input().split()]
	if abs(X - 2 * Y) % 2 == 0 and X > 0:
		print('YES')
	elif abs(X - 2 * Y) % 2 == 0 and Y % 2 == 0:
		print('YES')
	else:
		print('NO')


import math
for i in range(int(input())):
	(x, y) = list(map(int, input().split()))
	if x % 2 != 0 or (x == 0 and y % 2 != 0):
		print('NO')
	else:
		print('YES')