You are given an integer N. Let A be an N \times N grid such that A_{i, j} = i + N\cdot(j-1) for 1 ≤ i, j ≤ N. For example, if N = 4 the grid looks like:

You start at the top left corner of the grid, i.e, cell (1, 1). You would like to reach the bottom-right corner, cell (N, N). To do so, whenever you are at cell (i, j), you can move to either cell (i+1, j) or cell (i, j+1) provided that the corresponding cell lies within the grid (more informally, you can make one step down or one step right).

The *score* of a path you take to reach (N, N) is the sum of all the numbers on that path.

You are given an integer K that is either 0 or 1. Is there a path reaching (N, N) such that the parity of its score is K?

Recall that the parity of an integer is the (non-negative) remainder obtained when dividing it by 2. For example, the parity of 246 is 0 and the parity of 11 is 1. In other words, an even number has parity 0 and an odd number has parity 1.

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

- The first line contains a single integer T — the number of test cases. Then the test cases follow.
- The first and only line of each test case contains two space-separated integers N and K.

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

- For each test case, output the answer on a new line — YES if such a path exists, and NO otherwise.

Each character of the output may be printed in either uppercase or lowercase, i.e, the strings YES, yEs, and yes will all be treated as identical.

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

$1 ≤ T ≤ 10^{5}$
$1 ≤ N ≤ 10^{9}$
$K \in \{0, 1\}$

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

----- Sample Output 1 ------ 
No
Yes
Yes
Yes

----- explanation 1 ------ 
Test case $1$: There is only one possible path, which starts and ends at the same cell. The score of this path is $1$, which is odd. An even score is impossible.

Test case $2$: The following path has an even score for $N = 2$:

Test case $3$: The following path has an odd score for $N = 2$:

Test case $4$: The following path has an odd score for $N = 3$:

Source: codechef | Difficulty: EASY
Tags: Constructive algorithms

Mathematics

Ad-hoc


Solutions:
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	print('No' if n % 2 and (not k) else 'Yes')


for i in range(int(input())):
	(a, b) = [int(x) for x in input().split()]
	if a % 2 and (not b):
		print('No')
	else:
		print('Yes')


s = int(input())
for i in range(s):
	(a, b) = map(int, input().split(' '))
	if b == 0:
		n = a + b
		if n % 2 == 0:
			print('Yes')
		else:
			print('No')
	else:
		print('Yes')


for i in range(int(input())):
	(n, k) = map(int, input().split())
	if n == 1:
		if k == 1:
			print('Yes')
		else:
			print('No')
	elif n & 1 and k == 1 or n % 2 == 0:
		print('Yes')
	else:
		print('No')


for i in range(int(input())):
	(N, K) = map(int, input().split())
	if N % 2 != 0 == K:
		print('No')
	else:
		print('Yes')


t = int(input())
while t > 0:
	(n, k) = map(int, input().split(' '))
	if n == 1 and k == 0:
		print('No')
	elif n == 1 and k == 1:
		print('Yes')
	elif n % 2 == 0:
		print('Yes')
	elif k % 2 == 0:
		print('No')
	else:
		print('Yes')
	t -= 1


for j in range(int(input())):
	(a, b) = map(int, input().split())
	if a % 2 == 1 and b % 2 == 0:
		print('No')
	else:
		print('Yes')


for _ in range(int(input())):
	(N, k) = map(int, input().split())
	if N % 2 == 0 or (N % 2 != 0 and k == 1):
		print('Yes')
	else:
		print('No')


T = int(input())
for i in range(T):
	(N, K) = [int(i) for i in input().split()]
	if N % 2 == 0:
		print('Yes')
	elif N % 2 != 0 and K == 1:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if n % 2 == 0:
		print('Yes')
	elif k == 1:
		print('Yes')
	else:
		print('No')


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split(' '))
	if k == 0:
		if n % 2 == 0:
			print('Yes')
		else:
			print('No')
	else:
		print('Yes')


for i in range(int(input())):
	(a, b) = map(int, input().split())
	if a % 2 == 0:
		print('Yes')
	elif b == 1:
		print('Yes')
	else:
		print('No')


T = int(input())
for _ in range(T):
	(a, b) = map(int, input().split())
	if a % 2 == 0:
		print('Yes')
	elif b == 0:
		print('No')
	else:
		print('Yes')


for x in range(int(input())):
	(N, parity) = list(map(int, input().split()))
	if N % 2 == 1 and parity % 2 == 0:
		print('No')
	else:
		print('Yes')


t = int(input())
while t != 0:
	(n, m) = map(int, input().split())
	if n % 2 == 0:
		print('Yes')
	elif m == 1:
		print('Yes')
	else:
		print('No')
	t -= 1


for _ in range(int(input())):
	(A, B) = map(int, input().split())
	if A % 2 == 0:
		print('Yes')
	else:
		print('No') if B % 2 == 0 else print('Yes')