#P10690. Fotile 模拟赛 L

Fotile 模拟赛 L

Problem Description

FOTILE is given a sequence AA of length NN. To save the Earth, he wants to know the maximum subarray XOR\rm XOR sum within certain intervals.

That is, for each query, you need to compute

maxlijrk=ijak\max_{l\le i\le j\le r}\bigoplus_{k=i}^{j} a_k

To reflect online operations, for a query (x,y)(x,y):

  • $l = \min ( ((x+{\rm lastans}) \bmod N)+1 , ((y+{\rm lastans}) \bmod N)+1)$.
  • $r = \max ( ((x+{\rm lastans}) \bmod N)+1 , ((y+{\rm lastans}) \bmod N)+1)$.

Here lastans\rm lastans is the answer to the previous query, and it is 00 at the beginning.

Input Format

The first line contains two integers NN and MM.

The second line contains NN positive integers, where the ii-th number is AiA_i, and there may be extra spaces.

The next MM lines each contain two numbers xx and yy, representing a query.

Output Format

Output MM lines. The ii-th line contains one positive integer, the answer to the ii-th query.

3 3
1 4 3 
0 1
0 1
4 3
5
7
7

Hint

For all testdata, N=12000N=12000, M=6000M=6000, and xx, yy, and aia_i are all within the range of signed int.

Translated by ChatGPT 5