Great Party
时间限制: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 n piles of stones on the table. The i-th pile has a_i 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 q 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 n, q ().

The second line contains n integers ().

The i-th of the next q lines contains two integers l_i, r_i ().

输出描述:

The output contains q 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

输出

复制
3
2
3
5
5
示例2

输入

复制
4 5
5 6 7 8
1 2
2 3
3 4
1 3
2 4

输出

复制
3
3
3
6
6