Given the coordinates (x, y) of a point in 2-D plane. Find if it is possible to reach (x, y) from (0, 0). The only possible moves from any coordinate (i, j) are as follows: 
 
Go to the point with coordinates (i + 1, j + 1).
Go to the point with coordinates (i + 1, j - 1)
Go to the point with coordinates (i - 1, j  + 1).
Go to the point with coordinates (i - 1, j - 1).

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

- First line will contain T, number of testcases. Then the testcases follow.
- Each testcase contains of a single line of input, two integers x, y.

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

For each test case, print YES if it is possible to reach (x, y) from (0, 0), otherwise print NO.

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 ≤ 2\cdot10^{4}$
$-10^{9} ≤ x, y ≤ 10^{9}$

----- Sample Input 1 ------ 
6
0 2
1 2
-1 -3
-1 0
-3 1
2 -1

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

----- explanation 1 ------ 
Test case $1$: A valid sequence of moves can be: $\;(0, 0) \rightarrow (1, 1) \rightarrow (0, 2)$.

Test case $2$: There is no possible way to reach the point $(1, 2)$ from $(0, 0)$.

Test case $3$: A valid sequence of moves can be: $\;(0, 0) \rightarrow (-1, -1) \rightarrow (0, -2) \rightarrow (-1, -3)$.

Difficulty: EASY
Tags: Constructive algorithms

Mathematics

Ad-hoc

Starter code:

Solutions:
(x1, y1) = (0, 0)
for i in range(int(input())):
	(x2, y2) = map(int, input().split())
	if abs(x2 + y2) % 2 == 0:
		print('YES')
	else:
		print('NO')


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


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


for i in range(int(input())):
	(x, y) = map(int, input().split())
	r = x + y
	if (x + y) % 2 == 0:
		print('YES')
	else:
		print('NO')


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


for i in range(int(input())):
	a = [int(x) for x in input().split()]
	if a[0] % 2 == a[1] % 2:
		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())
for _ in range(IN()):
	(n, r) = IP()
	s = abs(n) + abs(r)
	print('NO' if s & 1 else 'YES')


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	if x + y & 1:
		print('NO')
	else:
		print('YES')


a = int(input())
for i in range(a):
	(b, c) = map(int, input().split())
	if (c - b) % 2 == 0:
		print('YES')
	else:
		print('NO')


a = int(input())
for i in range(a):
	(x, y) = map(int, input().split(' '))
	D = x - y
	d = abs(D)
	if d % 2 != 1:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	(x, y) = map(int, input().split())
	print('YES' if abs(x + y) % 2 == 0 else 'NO')
	t -= 1


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


for o in range(int(input())):
	(x, y) = list(map(int, input().split()))
	xy = abs(x) + abs(y)
	if xy % 2 == 0:
		print('YES')
	else:
		print('NO')


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


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


for tc in range(int(input())):
	(a, b) = map(int, input().split())
	if abs(abs(a) + abs(b)) % 2 == 1:
		print('NO')
	else:
		print('YES')


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


for i in range(int(input())):
	(x, y) = map(int, input().split())
	tot = abs(abs(x) - abs(y))
	if tot % 2 == 0 or abs(x) == abs(y):
		print('YES')
	else:
		print('NO')


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


import sys

def get_ints():
	return map(int, sys.stdin.readline().strip().split())
for _ in range(int(input())):
	(a, b) = get_ints()
	if abs(a - b) % 2 == 0:
		print('YES')
	else:
		print('NO')


T = int(input())
for i in range(T):
	cor = list(map(int, input().split()))
	num = cor[0] - cor[1]
	if abs(num) % 2 == 0:
		print('YES')
	else:
		print('NO')


T = int(input())
for t in range(T):
	N = str(input()).split(' ')
	A = int(N[0])
	B = int(N[1])
	if (A + B) % 2 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	(x, y) = list(map(int, input().split()))
	sum = x + y
	if sum % 2 == 0:
		print('YES')
	else:
		print('NO')
	t = t - 1