Farmer John is sending a cow to compete in the International Bovine Olympiad, but he's too lazy to write problems for a contest, so he does the next most reasonable thing: a fighting tournament!
Farmer John has $$$2^n$$$ cows standing in a line, with the $$$i$$$-th cow having a skill level of $$$a_i$$$. Each cow starts in a stack containing only itself, and the skill level of the stack is equal to the XOR-sum$$$^{\text{∗}}$$$ of the skill levels of all the cows in it. For example, if the stack consists of cows $$$1, 3, 9$$$ from bottom to top, then the skill level of the stack is $$$1 \oplus 3 \oplus 9 = 11$$$.
The following process repeats until there is only one stack.
In order to make this more exciting, Farmer John created $$$q$$$ potions, such that the $$$i$$$-th potion sets the skill level of the cow who drinks it to $$$c_i$$$. Farmer John wants to test his potions on the cows, and so he gives the $$$i$$$-th potion to cow $$$b_i$$$ and then runs the tournament. For each trial, Farmer John wants to know how many cows are above the cow that was given the potion in the final stack.
Farmer John's potions wear off quickly, so when the tournament ends, the cow that was given the potion will have its skill level return to what it originally was. In other words, all queries are independent.
$$$^{\text{∗}}$$$The XOR-sum of an array $$$x_1, x_2, \ldots, x_y$$$ is equal to $$$x_1 \oplus x_2 \oplus x_3 \ldots x_{y-1} \oplus x_y$$$ where $$$\oplus$$$ denotes the bitwise XOR operation.
The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases.
The first line of each test case contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n \le 18$$$, $$$1 \le q \le 2 \cdot 10^5$$$) — where $$$2^n$$$ is equal to the number of cows in the tournament and $$$q$$$ is the number of potions.
The second line contains $$$2^n$$$ integers $$$a_1, a_2, \ldots, a_{2^n}$$$ ($$$1 \le a_i \le 2^{30}$$$) — the skill levels of the cows.
The next $$$q$$$ lines contain two integers $$$b_i$$$ and $$$c_i$$$ ($$$1 \le b_i \le 2^n$$$, $$$1 \le c_i \le 2^{30}$$$) — the index of the cow that is given the potion and the new skill level of the cow.
It is guaranteed that the sum of $$$2^n$$$ over all test cases does not exceed $$$2^{18} = 262144$$$ and that the sum of $$$q$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.
For each trial, output how many cows are above the cow that was given the potion in the final line.
42 21 3 5 71 14 81 21 31 41 23 41 8 3 10 2 5 7 15 38 121 92 12 11 2 3 43 1
100150231
For the first round of the first test case, the skill levels of the cows don't change, and the matches go as follows:
A visualization of the round is shown below.
For the second round of the first test case, cow $$$4$$$ 's skill level is now $$$8$$$, and the matches go as follows: