Expert2700

MEX OR Mania

Codeforces
View on Codeforces
Time: 4 secondsMemory: 1024 megabytes

An integer sequence b_1, b_2, …, b_n is good if mex(b_1, b_2, …, b_n) - (b_1 | b_2 | … | b_n) = 1. Here, mex(c) denotes the MEX^∗ of the collection c, and | is the bitwise OR operator.

Shohag has an integer sequence a_1, a_2, …, a_n. He will perform the following q updates on a:

After each update, help him find the length of the longest good subarray^† of a.

Input

Each test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^4). The description of the test cases follows. The first line of each test case contains two space-separated integers n and q (1 ≤ n, q ≤ 10^5).The second line of each test case contains n integers a_1, a_2, …, a_n (0 ≤ a_i ≤ n).The next q lines of each test case are of the following form: i x (1 ≤ i, x ≤ n) — it means you should increase a_i by x. It is guaranteed that the sum of n over all test cases doesn't exceed 10^5 and the sum of q doesn't exceed 10^5.

Output

For each test case, output q lines — on the i-th line output the length of the longest good subarray of a after the i-th update.

Examples

Input
2 6 3 0 0 1 0 1 0 6 1 3 2 6 3 3 1 1 3 1 1 1
Output
6 3 2 0

Note

In the first test case, after the first update, the array becomes [0, 0, 1, 0, 1, 1], and here the whole array is good because mex([0, 0, 1, 0, 1, 1]) - (0 | 0 | 1 | 0 | 1 | 1) = 2 - 1 = 1.After the second update, the array becomes [0, 0, 3, 0, 1, 1], and here the subarray [0, 1, 1] has the maximum length among all the good subarrays.Finally, after the third update, the array becomes [0, 0, 3, 0, 1, 4], and here the subarrays [0, 0] and [0, 1] both have the maximum length among all the good subarrays.

bitmasksbrute forcedata structuresdsuimplementation

Discussion

(0)
Sign in to join the discussion.
Loading editor...
0 online