eolymp
bolt
Try our new interface for solving problems
Problems

AND = OR

AND = OR

Let’s call an array of integers [b1, b2, ..., bm] good, if we can partition all of its elements into 2 nonempty 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 [a1, a2, ..., an], and have to answer q queries of form: is subarray [al, al+1, ..., ar] good?

Input

The first line contains two integer n, q (1n105, 1q105) - the length of the array and the number of the associated queries.

The second line contains n integers a1, a2, ..., an (0ai230 - 1) - the elements of the array.

The i-th of the next q lines contains 2 integers li, ri (1lirin), describing the i-th query.

Output

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

Time limit 3 seconds
Memory limit 128 MiB
Input example #1
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 example #1
NO
NO
YES
YES
YES
NO
YES
YES
YES
NO
NO
YES
NO
NO
NO
Source 2020 SEERC South Eastern European Regional Programming Contest, Vinnica & Bucharest, May 23, Problem H