Roger has a strange array consisting of elements, each of which is either
or
. He also has
queries, each of the form
which means that Roger wants to know whether there exists a subarray
where
whose sum of elements is exactly
.
Constraints
For all subtasks:
Each element of the array is either or
.
Subtask 1 [20%]
Subtask 2 [80%]
No additional constraints.
Input Specification
On the first line, there are two space-separated integers, and
, denoting the number of elements in the array and the number of queries.
On the second line, there are space-separated integers, the elements of the array.
On the next lines, there are three space-separated integers,
, denoting a query.
Output Specification
Output lines, where the
-th line is
YES
if there exists a subarray satisfying the conditions of Roger's -th query, or
NO
otherwise.
Sample Input
7 3
1 2 2 1 1 2 1
2 4 3
1 7 8
2 5 7
Sample Output
YES
YES
NO
Comments