时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld
题目描述
Grammy joined a great party.
There is an interesting game at the party. There are

piles of stones on the table. The

-th pile has

stones in it. Two players participate in the game and operate the stones in turn.
In each player's turn, the player will do the following two steps:
- Select a non-empty pile of stones, select a positive amount of stones to remove from it.
- Keep the remaining stones in the pile still or merge them all into another non-empty pile of stones.
Those who cannot operate lose the game.
Now, Grammy has

questions. For each question, she asks you how many sub-segments of

satisfy that if the piles in the segment are taken out alone for the game, the first player will win.
输入描述:
The first line contains two integers
(
).
The second line contains
integers
(
).
The
-th of the next
lines contains two integers
(
).
输出描述:
The output contains
lines. Each line contains a single integer, denoting the answer to the question.
示例1
输入
复制
4 5
1 2 2 4
1 2
2 3
3 4
1 3
2 4
示例2
输入
复制
4 5
5 6 7 8
1 2
2 3
3 4
1 3
2 4