8576: Great Party

内存限制:256 MB 时间限制:1 S
题面:传统 评测方式:文本比较 上传者:
提交:1 通过:1

题目描述

链接:https://ac.nowcoder.com/acm/contest/33192/K
来源:牛客网
Grammy joined a great party.

There is an interesting game at the party. There are nnn piles of stones on the table. The iii-th pile has aia_iai 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 qqq questions. For each question, she asks you how many sub-segments of [l,r][l,r][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,qn, qn,q (1≤n,q≤1051 \leq n, q \leq 10^51n,q105).
The second line contains nnn integers a1,a2,…,ana_1,a_2,\ldots,a_na1,a2,,an (1≤ai≤1061 \leq a_i \leq 10^61ai106).
The iii-th of the next qqq lines contains two integers li,ril_i, r_ili,ri (1≤li≤ri≤n1 \leq l_i \leq r_i \leq n1lirin).

输出格式


The output contains qqq lines. Each line contains a single integer, denoting the answer to the question.

输入样例 复制

4 5
1 2 2 4
1 2
2 3
3 4
1 3
2 4

输出样例 复制

3
2
3
5
5

分类标签