题目描述

Nim is a mathematical game of strategy in which two players take turns removing objects from distinct heaps. On each turn, a player must remove at least one object, and may remove any number of objects provided they all come from the same heap |Fṝõṃ Wìǩìqèḋìa«țȟè ḟṝèè èñćẏćḽõqèḋìa¦. **The goal of the game is to avoid being the pla**yer who doesn’t have any object to remove. The player who remove the last project is the winner.

Now KK and TT are playing Nim game with the optimal strategy. There are**n** heaps of stones. The number of stones in *i*‑th heap is *a*_{i}. They play this game **m** times, and KK is the player making the first move. During the *i*‑th time they play the game on the heaps whose index in interval** [****l**_{i}** , r**_{i}**]**. KK wants to know whether he has a winning strategy or not.

Now KK and TT are playing Nim game with the optimal strategy. There are

输入

The input consists of several test cases. The first line of the input gives the number of test cases,*T(1 ≤ T ≤ 10*^{3}*)*.

For test case, the first line contains two integers*n(1 ≤ n ≤ 10*^{6}* )* and *m(1 ≤ m ≤ 10*^{6}*)*, representing the number of heap of stones and the
game times.

The second line contains* n* positive integers *a*_{1}*, a*_{2}*, ⋯ , a*_{n}* (1 ≤ a*_{i}* ≤ 10*^{9}*)*, representing The number of stones in *i*‑th heap.

In the next*m* lines, each line contains two integers* **li, ri* , which means the $i: KaTeX parse error: $ within math mode$th game is played on the interval*[l*_{i}* , r*_{i}*]*.

It’s guaranteed that* ∑ n ≤ 2 × 10*^{6 }and *∑ m ≤ 2 × 10*^{6}．

For test case, the first line contains two integers

The second line contains

In the next

It’s guaranteed that

输出

For each test case, let* f*_{i} represents the answer of the *i*-th game.

If KK has a winning strategy in the*i*-th game then *f*_{i}*=1*, otherwise* f*_{i}*=0*. Please output* ∑ f*_{i}* ∗ 2*^{m-i}* mod 10 + 7，in which 1 ≤ i ≤ m*．

If KK has a winning strategy in the

样例输入
Copy

```
3
2 1
1 1
1 2
2 1
1 2
1 2
3 2
1 2 2
1 2
2 3
```

样例输出 Copy

```
0
1
2
```

来源/分类