AlgoUniversity
  • Go Back
Discussion
Grid Moves :

Author

Ayush Gangwani

Difficulty Level : Medium

Submissions : 414

Asked In : PhonePe

Marks :15

: 6 | : 0

You are standing at coordinates $$$(1,1)$$$ of an infinite 2D plane. From cell $$$(x,y)$$$, you can move to either $$$(2x,y)$$$ or $$$(x,2y)$$$ or $$$(x-y,y)$$$ or $$$(x,y-x)$$$.

Your task is to find out if you can reach cell $$$(n,m)$$$ through a series of moves.

Input

The first line of input contains an integer $$$t$$$ $$$(1 \le t \le 10^5)$$$ — the number of testcases. The description of $$$t$$$ testcases follows.

The first and only line of each testcase contains two integers $$$n$$$ and $$$m$$$ $$$(1 \le n,m \le 10^{18})$$$ — the coordinates of the destination as specified in the problem statement.

Output

For each testcase, print "Yes" if you can reach the cell $$$(n,m)$$$ through a series of moves and "No" otherwise.

Example

Input
4
1 2
3 4
4 7
10 10
Output
Yes
Yes
Yes
No

Note

In sample test case 1, we can simply use the second move to reach $$$(1,2)$$$ from $$$(1,1)$$$.

In sample test case 2, one of the ways to reach $$$(3,4)$$$ is $$$(1,1)\rightarrow (2,1)\rightarrow (4,1)\rightarrow (3,1)\rightarrow (3,2)\rightarrow (3,4)$$$.

In sample test case 3, one of the ways to reach $$$(4,7)$$$ is $$$(1,1)\rightarrow (1,2)\rightarrow (1,4)\rightarrow (1,8)\rightarrow (1,7)\rightarrow (2,7)\rightarrow (4,7)$$$.

In sample test case 4, It can be proved that you cannot reach $$$(10,10)$$$ through any series of moves.

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.