## GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

## [Solution] Path Parity CodeChef Solution | CodeChef Problem Solution 2022

You are given an integer $N$. Let $A$ be an $N×N$ grid such that ${A}_{i,j}=i+N\cdot \left(j-1\right)$ for $1\le i,j\le N$. For example, if $N=4$ the grid looks like: You start at the top left corner of the grid, i.e, cell $\left(1,1\right)$. You would like to reach the bottom-right corner, cell $\left(N,N\right)$. To do so, whenever you are at cell $\left(i,j\right)$, you can move to either cell $\left(i+1,j\right)$ or cell $\left(i,j+1\right)$ 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 $\left(N,N\right)$ 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 $\left(N,N\right)$ 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 YESyEs, and yes will all be treated as identical.

### Constraints

• $1\le T\le {10}^{5}$
• $1\le N\le {10}^{9}$
• $K\in \left\{0,1\right\}$