Sometimes it happens#12346

Sometimes it happens

2 seconds
256 megabytes
Very hard

Sometimes in life, there comes a moment when you want to hear answers to your queries.

Such a moment has come in Sergey’s life. He invented a very interesting problem and gave it to you to solve.

He has an array , which consists only of s and s, and you can perform the following operation on it:

The array will be considered good if you manage to repaint the entire array into ones.

However, since Sergey is going through a difficult period in his life, he decided to complicate his problem and give you queries of the form [l, r]. You need to respond to the query by stating whether the subsegment [l, r] of array is good.

Input

The first line contains three integers , , (1 \le n, k, q \le 10^6) — the length of the array , the number , and the number of queries.

The second line contains integers a_1, a_2, \dots, a_n (0 \le a_i \le 1) — Sergey’s array.

Each of the next lines contains two integers and (1 \le l; l+2 \cdot k-1 \le r \le n) — Sergey’s queries.

Output

You need to answer each query. If the array is not good, output «NO», otherwise output «YES».

Examples

Example 1

Loading
Loading

Note

Query : Subarray [1,0,1,0,0,1,0,0,0,1]. First move on : subarray [1,0,1,0,0,1] has zeros and ones, repaint \to [1,1,1,1,1,1,0,0,0,1]. Second move on . Answer: YES.

Query : Subarray [0,1,1,1,1,0,0] — it is impossible to cover all zeros with permissible operations. Answer: NO.

Query : Subarray [0,0,1,0,1,1,1]. Move on : [0,0,1,0,1,1] — zeros, ones, one move completes. Answer: YES.

Query : Subarray [0,0,0,1,0,1,1] — zeros, ones. This is impossible to accomplish. Answer: NO.

Query : Subarray [1,0,1,0,0,1] — exactly zeros and ones, one move for the entire segment. Answer: YES.

Scoring

  1. ( points): q = 1; l_1 = 1; r_1 = n;

  2. ( points): n \le 10;

  3. ( points): n,q \le 5\,000;

  4. ( points): l_i = 1;

  5. ( points): k = 1;

  6. ( points): k \le 50;

  7. ( points): r_i - l_i + 1 = 4 \cdot k;

  8. ( points): If the answer is «YES», then it can be done in just one operation.

  9. ( points): Without additional constraints.