#P9671. [ICPC 2022 Jinan R] Identical Parity
[ICPC 2022 Jinan R] Identical Parity
题目描述
Let the value of a sequence be the sum of all numbers in it.
Determine whether there exists a permutation of length such that the values of all subsegments of length of the permutation share the same parity. The values share the same parity means that they are all odd numbers or they are all even numbers.
A subsegment of a permutation is a contiguous subsequence of that permutation. A permutation of length is a sequence in which each integer from to appears exactly once.
输入格式
The first line contains one integer , the number of test cases.
For each test case, the only line contains two integers .
输出格式
For each test case, output (without quotes) if there exists a valid permutation, or (without quotes) otherwise.
You can output and in any case (for example, strings , and will be recognized as positive responses).
3
3 1
4 2
5 3
No
Yes
Yes
提示
In the first test case, it can be shown that there does not exist any valid permutation.
In the second test case, is one of the valid permutations. Its subsegments of length are . Their values are , respectively. They share the same parity.
In the third test case, is one of the valid permutations. Its subsegments of length are . Their values are , respectively. They share the same parity.