PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000144. Các đoạn có XOR bằng nhau (Equal XOR Segments)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Các đoạn có XOR bằng nhau (Equal XOR Segments)

Equal XOR Segments

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

You are given an array a1,a2,…,ana_1,a_2,\ldots,a_n of nonnegative integers. A consecutive subarray is called valid if it can be partitioned into at least two nonempty consecutive parts such that the bitwise XOR of each part has the same value. Every element must belong to exactly one part, and the original order is preserved.

For each of qq queries (l,r)(l,r), determine whether the subarray al,al+1,…,ara_l,a_{l+1},\ldots,a_r is valid. We denote bitwise XOR by ⊕\oplus.

Input

  • The first line contains n,qn,q, the array length and the number of queries.
  • The second line contains nn integers a1,a2,…,ana_1,a_2,\ldots,a_n.
  • Each of the next qq lines contains two indices l,rl,r. Indices are 11-based.

Output

Print YES or NO on a separate line for each query, in order.

Subtasks

  • Subtask 1 (20 points): 2≤n≤402\le n\le 40; 1≤q≤401\le q\le 40; 0≤ai<2100\le a_i<2^{10}; 1≤l<r≤n1\le l<r\le n for every query.
  • Subtask 2 (30 points): 2≤n≤50002\le n\le 5000; 1≤q≤50001\le q\le 5000; 0≤ai<2200\le a_i<2^{20}; 1≤l<r≤n1\le l<r\le n for every query.
  • Subtask 3 (50 points): 2≤n≤2⋅1052\le n\le 2\cdot10^5; 1≤q≤2⋅1051\le q\le 2\cdot10^5; 0≤ai<2300\le a_i<2^{30}; 1≤l<r≤n1\le l<r\le n for every query.

Examples

Input

5 3
1 1 2 3 0
1 5
2 3
1 2

Output

YES
NO
YES

Explanation

  • For [1,5][1,5], the partition [1][1], [1][1], [2,3,0][2,3,0] has XOR values 11, 11, and 2⊕3⊕0=12\oplus3\oplus0=1, so the answer is YES.
  • For [2,3][2,3], the elements [1,2][1,2] can only be split into [1][1] and [2][2], whose XOR values differ; hence NO.
  • For [1,2][1,2], [1][1] and [1][1] have equal XOR values, so the answer is YES.