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 player 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 ai. 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 [li , ri]. KK wants to know whether he has a winning strategy or not.
The input consists of several test cases. The first line of the input gives the number of test cases,T(1 ≤ T ≤ 103).
For test case, the first line contains two integers n(1 ≤ n ≤ 106 ) and m(1 ≤ m ≤ 106), representing the number of heap of stones and the
The second line contains n positive integers a1, a2, ⋯ , an (1 ≤ ai ≤ 109), 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[li , ri].
It’s guaranteed that ∑ n ≤ 2 × 106 and ∑ m ≤ 2 × 106．
For each test case, let fi represents the answer of the i-th game.
If KK has a winning strategy in the i-th game then fi=1, otherwise fi=0. Please output ∑ fi ∗ 2m-i mod 10 + 7，in which 1 ≤ i ≤ m．
1 2 2