시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB368832.000%

문제

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:

  1. Select a non-empty pile of stones, select a positive amount of stones to remove from it.
  2. 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 $[l,r]$ 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$ and $q$ ($1 \leq n, q \leq 10^5$).

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \leq a_i \leq 10^6$).

The $i$-th of the next $q$ lines contains two integers $l_i$ and $r_i$ ($1 \leq l_i \leq r_i \leq n$).

출력

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

예제 출력 1

3
2
3
5
5

예제 입력 2

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

예제 출력 2

3
3
3
6
6