Chef has two numbers A and B.

In one operation, Chef can choose either A or B and multiply it by 2.

Determine whether he can make both A and B equal after any number (possibly, zero) of moves.

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

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

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

For each test case, output YES if Chef can make both numbers equal, NO otherwise.

Note that the checker is case-insensitive i.e. YES, Yes, yes, yES are all considered same.

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

$1 ≤ T ≤ 2500$
$1 ≤ A, B ≤ 50$

----- Sample Input 1 ------ 
4
5 20
6 6
12 2
50 20

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

----- explanation 1 ------ 
Test case $1$: Chef can multiply $A$ by $2$ twice and both $A$ and $B$ will become $20$.

Test case $2$: Both numbers are already equal.

Test case $3$: It can be shown that $A$ and $B$ cannot be made equal.

Test case $4$: It can be shown that $A$ and $B$ cannot be made equal.

Difficulty: EASY
Tags: Bit manipulation

Mathematics
Skill types: Bit manipulation

Starter code:

Solutions:
for i in range(int(input())):
	(a, b) = map(int, input().split())
	mi = min(a, b)
	ma = max(a, b)
	g = False
	while mi < ma:
		mi *= 2
	if mi == ma:
		g = True
	if g == True:
		print('YES')
	else:
		print('NO')


import math
for i in range(int(input())):
	x = [int(x) for x in input().split()]
	a = math.log(max(x) / min(x), 2)
	if int(a) == a:
		print('YES')
	else:
		print('NO')


n = int(input())
for _ in range(n):
	(x, y) = list(map(int, input().split()))
	smol = min(x, y)
	chonk = max(x, y)
	while smol < chonk:
		smol *= 2
	if smol == chonk:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	x = min(a, b)
	y = max(a, b)
	while x < y:
		x = x * 2
	if x == y:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(a, b) = map(int, input().split())
	c = min(a, b)
	d = max(a, b)
	while c < d:
		c *= 2
	if c == d:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	(x, y) = map(int, input().split(' '))
	if x == y:
		print('YES')
	else:
		a = min(x, y)
		b = max(x, y)
		flag = 0
		for j in range(a, 51):
			a *= 2
			if a == b:
				flag = 1
				break
		if flag == 1:
			print('YES')
		else:
			print('NO')


for i in range(int(input())):
	(a, b) = map(int, input().split())
	if a == b:
		print('YES')
	else:
		x = min(a, b)
		m = max(a, b)
		for j in range(max(a, b)):
			sq = x * 2
			x = sq
			if x == m:
				print('YES')
				break
			elif sq > m:
				print('NO')
				break


n = int(input())
for i in range(n):
	(a, b) = list(map(int, input().split()))
	m = min(a, b)
	if m == a:
		other = b
	else:
		other = a
	while True:
		if m < other:
			m = m * 2
		elif m == other:
			print('YES')
			break
		elif m > other:
			print('NO')
			break


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	s = 0
	if a == b:
		print('YES')
	else:
		r = min(a, b)
		n = max(a, b)
		while r <= n:
			r = r * 2
			if r == n:
				s += 1
				break
		if s == 0:
			print('NO')
		else:
			print('YES')


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	x = max(a, b)
	y = min(a, b)
	i = 1
	flag = 0
	while True:
		r = i * y
		if r == x:
			flag = 1
			break
		if r > x:
			break
		i *= 2
	if flag == 1:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	while a < b:
		a *= 2
	if a == b:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	m = min(a, b)
	buff = 1
	while m < max(a, b):
		m = m * 2
	if m == max(a, b):
		print('YES')
	else:
		print('NO')


T = int(input())
for _ in range(T):
	(A, B) = map(int, input().split())
	flag = False
	if A == B:
		flag = True
	elif A < B:
		(A, B) = (B, A)
	while B < A:
		B = B * 2
		if B == A:
			flag = True
	if flag == False:
		print('NO')
	elif flag == True:
		print('YES')


def code():
	cases = int(input())
	for _ in range(cases):
		(A, B) = map(int, input().split(' '))
		if A == B:
			print('YES')
			continue
		if A > B:
			while A != B and B < A:
				B *= 2
			if A == B:
				print('YES')
				continue
		if B > A:
			while A != B and A < B:
				A *= 2
			if A == B:
				print('YES')
				continue
		print('NO')
code()


for i in range(int(input())):
	(a, b) = map(int, input().split())
	l = [1, 2, 4, 8, 16, 32]
	c = max(a, b) / min(a, b)
	if c in l:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a == b:
		print('YES')
	elif a < b:
		while a < b:
			a *= 2
		if a == b:
			print('YES')
		else:
			print('NO')
	elif a > b:
		while b < a:
			b *= 2
		if a == b:
			print('YES')
		else:
			print('NO')


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	z = min(a, b)
	c = max(a, b)
	if a == b:
		print('YES')
	else:
		for i in range(c):
			z *= 2
			if z == c:
				print('YES')
				break
		else:
			print('NO')


n1 = int(input())
for _ in range(n1):
	(a, b) = map(int, input().split())
	if a < b:
		n = a
		m = b
	else:
		n = b
		m = a
	if a > b or b > a:
		while 1:
			n *= 2
			if n == m:
				print('YES')
				break
			elif n > m:
				print('NO')
				break
	elif a == b:
		print('YES')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	if n > m:
		a = m
		b = n
	else:
		a = n
		b = m
	if n > m or m > n:
		while 1:
			a *= 2
			if a == b:
				print('YES')
				break
			elif a > b:
				print('NO')
				break
	elif n == m:
		print('YES')


for i in range(int(input())):
	(A, B) = map(int, input().split())
	SMALL = min(A, B)
	BIG = max(A, B)
	while SMALL < BIG:
		SMALL = SMALL * 2
	if A == B or SMALL == BIG:
		print('YES')
	else:
		print('NO')


T = int(input())
for _ in range(T):
	(A, B) = map(int, input().split())
	while A < B and A != B:
		A *= 2
	while B < A and A != B:
		B *= 2
	if A == B:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	if x > y:
		b = y
		c = x
	else:
		b = x
		c = y
	a = 0
	while b <= c:
		if b == c:
			a += 1
			break
		else:
			b = b * 2
	if a == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	(x, y) = list(map(int, input().split()))
	z = min(x, y)
	z1 = max(x, y)
	c = 0
	if x == y:
		c = 1
	else:
		c = 0
		while z <= z1:
			z = z * 2
			if z == z1:
				c = 1
	if c == 1:
		print('YES')
	else:
		print('NO')


for l in range(int(input())):
	(A, B) = map(int, input().split(' '))
	a = max(A, B) / min(A, B)
	flag = True
	while a > 1:
		if a % 2 == 0:
			a /= 2
		else:
			flag = False
			print('NO')
			break
	if flag == True:
		print('YES')


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	mi = min(a, b)
	mx = max(a, b)
	if mx == mi:
		print('YES')
	else:
		while mx > mi:
			mi *= 2
		if mi == mx:
			print('YES')
		else:
			print('NO')


try:
	n = int(input())
	for i in range(n):
		(a, b) = map(int, input().split())
		mi = min(a, b)
		mx = max(a, b)
		if mx == mi:
			print('YES')
		else:
			while mx > mi:
				mi *= 2
			if mi == mx:
				print('YES')
			else:
				print('NO')
except:
	pass


for i in range(int(input())):
	(A, B) = map(int, input().split())
	mn = min(A, B)
	mx = max(A, B)
	while mn < mx:
		mn = mn * 2
	if mn == mx:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(x, y) = map(int, input().split())
	if x > y:
		(x, y) = (y, x)
	while x < y:
		x = x * 2
	if x == y:
		print('YES')
	else:
		print('NO')