#P10743. [SEERC 2020] AND = OR

[SEERC 2020] AND = OR

Problem Description

An array bb is called a "good array" if and only if bb can be split into two non-empty subarrays such that the OR\mathtt{OR} result of the first subarray is equal to the AND\mathtt{AND} result of the second subarray. For example, for {1,7,3,11}\{1,7,3,11\}, split it into {1,3}\{1,3\} and {7,11}\{7,11\}. Then 1 OR 3=31\ \mathtt{OR}\ 3 = 3 and 7 AND 11=37\ \mathtt{AND}\ 11 = 3, so it is a good array.

Now you are given an array aa of length nn and qq queries. In each query, given [l,r][l,r], determine whether {al,al+1,,ar1,ar}\{a_l, a_{l+1},\ldots,a_{r-1},a_{r}\} is a good array.

Input Format

The first line contains two integers n (1n105)n\ (1 \leq n \leq 10^5) and q (1q105)q\ (1 \leq q \leq 10^5).

The second line contains nn integers representing the sequence a (0ai2301)a\ (0\leq a_i \leq 2^{30}-1).

The next qq lines each contain two integers l,r (1lrn)l,r\ (1 \leq l \leq r \leq n), representing a query.

Output Format

For each query, if the subarray is good, output YES; otherwise output NO.

5 15
0 1 1 3 2
1 1
1 2
1 3
1 4
1 5
2 2
2 3
2 4
2 5
3 3
3 4
3 5
4 4
4 5
5 5
NO
NO
YES
YES
YES
NO
YES
YES
YES
NO
NO
YES
NO
NO
NO

Hint

Translated by ChatGPT 5