#P8845. Bitwise XOR of Prime Pairs
Bitwise XOR of Prime Pairs
Bitwise XOR of Prime Pairs
In this problem, you are given (T) queries. For each query, you are provided with two positive integers (x) and (y) which denote indices in the sequence of prime numbers. Let (p_x) be the (x)-th prime and (p_y) be the (y)-th prime. Your task is to determine whether the bitwise XOR of (p_x) and (p_y) equals 1; that is, to check if [ p_x \oplus p_y = 1 ] Recall that for any two integers (a) and (b), (a \oplus b = 1) if and only if (a) and (b) are consecutive integers (i.e. (|a - b| = 1)). Given that all primes except 2 are odd, the only pair of primes that are consecutive is (2) and (3). Hence, (p_x \oplus p_y = 1) if and only if one of (x, y) is 1 and the other is 2.
inputFormat
The first line contains an integer (T) ((1 \le T \le 10^5)) --- the number of queries. Each of the next (T) lines contains two space-separated positive integers (x) and (y) ((1 \le x, y \le 10^9)).
outputFormat
For each query, output a single line containing either YES
if (p_x \oplus p_y = 1) or NO
otherwise.
sample
3
1 2
2 1
2 2
YES
YES
NO
</p>