You are given two positive integers A and B. You need to construct two different binary strings (i.e, they are strings which consist of only 0s and 1s), which satisfy these two conditions:

Both the strings should be palindromes.
Each string should have exactly A 0s, and exactly B 1s in them.

Output Yes if two such different binary strings can be constructed and No otherwise.

Note: 
A string is said to be a palindrome, if the string and the reverse of the string are identical.
Two strings are said to be different if either their lengths are different, or if they differ in at least one character.

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

- The first line of input will contain a single integer T, denoting the number of test cases.
- Each test case contains two space-separated integers, A and B, in a new line.

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

For each test case, output on a new line 'Yes', if you can construct two different binary strings satisfying the conditions. If not, output 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 ≤ 10^{5}$
$1 ≤ A, B ≤ 10^{6}$

----- Sample Input 1 ------ 
3
2 2
2 3
3 3

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

----- explanation 1 ------ 
Test case $1$: Consider the binary strings $0110$ and $1001$. Both of them are palindromes, and both of them have exactly $2$ $0$s, and $2$ $1$s. Hence we can construct them, and so the answer is Yes.

Test case $2$: Consider the binary strings $01110$ and $10101$. Both of them are palindromes, and both of them have exactly $2$ $0$s, and $3$ $1$s. Hence we can construct them, and so the answer is Yes.

Test case $3$: There is no way to construct two such different strings. Hence the answer is No.

Difficulty: EASY
Tags: Mathematics

Constructive algorithms

Starter code:

Solutions:
for i in range(int(input())):
	(zero, one) = map(int, input().split())
	z = zero % 2
	o = one % 2
	if zero < 2 or one < 2:
		print('No')
	elif z == 1 and o == 1:
		print('No')
	else:
		print('Yes')


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


T = int(input())
for i in range(T):
	(A, B) = map(int, input().split())
	if A >= 2 and B >= 2:
		A = A % 2 + 2
		B = B % 2 + 2
		if A == 3 and B == 3:
			print('No')
		else:
			print('Yes')
	else:
		print('No')


for i in range(0, int(input())):
	list1 = list(map(int, input().split()))
	if list1[0] < 2 or list1[1] < 2:
		print('No')
	elif list1[0] % 2 != 0 and list1[1] % 2 != 0:
		print('No')
	else:
		print('Yes')


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


buddy = int(input())
for _ in range(buddy):
	(janu, cute) = map(int, input().split())
	if janu >= 2 and cute >= 2:
		janu = janu % 2 + 2
		cute = cute % 2 + 2
		if janu == 3 and cute == 3:
			print('No')
		else:
			print('Yes')
	else:
		print('No')


T = int(input())
for i in range(T):
	(A, B) = map(int, input().split())
	if A == 1 or B == 1:
		print('No')
	elif A % 2 != 0 and B % 2 != 0:
		print('No')
	else:
		print('Yes')


for i in range(int(input())):
	(x, y) = map(int, input().split())
	if x < 2 or y < 2:
		print('No')
	elif y % 2 == 0 or x % 2 == 0:
		print('Yes')
	else:
		print('No')


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


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


T = int(input())
for _ in range(T):
	(A, B) = list(map(int, input().split()))
	if A % 2 and B % 2:
		print('No')
	elif A == 1 or B == 1:
		print('No')
	else:
		print('Yes')


a = int(input())
for _ in range(a):
	(p, q) = list(map(int, input().split()))
	if p >= 2 and q >= 2:
		p = p % 2 + 2
		q = q % 2 + 2
		if p == 3 and q == 3:
			print('No')
		else:
			print('Yes')
	else:
		print('No')


a = int(input())
for _ in range(a):
	(p, q) = list(map(int, input().split()))
	if p < 2 or q < 2:
		print('No')
	elif p % 2 == 0 or q % 2 == 0:
		print('Yes')
	else:
		print('No')


tc = int(input())
for _ in range(tc):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	if a % 2 == 0 and b % 2 == 0:
		print('Yes')
	elif a % 2 != 0 and b % 2 == 0:
		if a > 1:
			print('Yes')
		else:
			print('No')
	elif a % 2 == 0 and b % 2 != 0:
		if b > 1:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


t = int(input())
for _ in range(t):
	(a, b) = [int(x) for x in input().split()]
	if a % 2 != 0 and b % 2 != 0 or a == 1 or b == 1:
		print('No')
	else:
		print('Yes')


t = int(input())
for i in range(t):
	a_b = input().split(' ')
	(a, b) = (int(a_b[0]), int(a_b[1]))
	if a + b <= 3:
		print('No')
	elif a % 2 != 0 and b % 2 != 0:
		print('No')
	elif a == 1 or b == 1:
		print('No')
	else:
		print('Yes')


t = int(input())
for tc in range(t):
	(n, m) = map(int, input().split())
	if n % 2 == 1 and m % 2 == 1 or (n < 2 or m < 2):
		print('No')
	else:
		print('Yes')


from math import ceil
for i in range(int(input())):
	(a, b) = map(int, input().split())
	if a % 2 == 0 and b % 2 == 0 and (a >= 2) and (b >= 2):
		print('Yes')
	elif a % 2 == 0 and b % 2 != 0 and (a >= 2) and (b >= 2) or (a % 2 != 0 and b % 2 == 0 and (a >= 2) and (b >= 2)):
		print('Yes')
	else:
		print('No')


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


q = int(input())
while q > 0:
	(a, b) = map(int, input().split())
	if a < 2 or b < 2:
		print('No')
	elif a % 2 != 0 and b % 2 != 0:
		print('No')
	else:
		print('Yes')
	q = q - 1


x = int(input())
rt = []
for mn in range(0, x):
	kl = str(input())
	up = kl.split(' ')
	tf = []
	for mkl in up:
		tf.append(int(mkl))
	rt.append(tf)
for jj in rt:
	if jj[0] % 2 == 0 and jj[1] % 2 == 0:
		if jj[0] != 0 and jj[1] != 0:
			print('Yes')
		else:
			print('No')
	elif jj[0] % 2 != 0 and jj[1] % 2 != 0:
		print('No')
	elif jj[0] == 1 or jj[1] == 1:
		print('No')
	elif jj[0] == 0 or jj[1] == 0:
		print('No')
	else:
		print('Yes')


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if a >= 2 and b >= 2:
		a = a % 2 + 2
		b = b % 2 + 2
		if a == 3 and b == 3:
			print('No')
		else:
			print('Yes')
	else:
		print('No')


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