408344: GYM103102 H AND = OR

Memory Limit:1024 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

H. AND = ORtime limit per test3 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard output

Let's call an array of integers $$$[b_1, b_2, \ldots, b_m]$$$ good, if we can partition all of its elements into $$$2$$$ non-empty groups, such that the bitwise AND of the elements in the first group is equal to the bitwise OR of the elements in the second group. For example, the array $$$[1, 7, 3, 11]$$$ is good, as we can partition it into $$$[1, 3]$$$ and $$$[7, 11]$$$, where $$$1$$$ OR $$$3 = 3$$$, and $$$7$$$ AND $$$11=3$$$.

You are given an array $$$[a_1, a_2, \ldots, a_n]$$$, and have to answer $$$q$$$ queries of form: is subarray $$$[a_l, a_{l+1}, \ldots, a_r]$$$ good?

Input

The first line of the input contains two integer $$$n$$$, $$$q$$$ ($$$1 \le n \le 10^5$$$, $$$1 \le q \le 10^5$$$) — the length of the array and the number of the associated queries.

The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 2^{30} - 1$$$) — the elements of the array.

The $$$i$$$-th of the next $$$q$$$ lines contains $$$2$$$ integers $$$l_i, r_i$$$ ($$$1 \le l_i \le r_i \le n)$$$ — describing the $$$i$$$-th query.

Output

For each query, output YES, if the correspondent subarray is good, and NO, if it's not.

ExampleInput
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
Output
NO
NO
YES
YES
YES
NO
YES
YES
YES
NO
NO
YES
NO
NO
NO

加入题单

上一题 下一题 算法标签: