CF2217B.Flip the Bit (Easy Version)

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

Flip the Bit (Easy Version)

This is the easy version of the problem. The difference between the versions is that in this version, there is exactly one special index (k=1k=1). You can hack only if you solved all versions of this problem.

You are given a binary array aa of length nn and kk special indices p1,p2,,pkp_1, p_2, \ldots, p_k (1pin1 \le p_i \le n). It is given that the values aia_i of all elements at special indices are the same (i. e., ap1=ap2==apka_{p_1} = a_{p_2} = \ldots = a_{p_k}).

In one operation, you can choose a range [l,r][l, r] (1lrn1 \le l \le r \le n) such that the range contains at least one special index (lpirl \le p_i \le r) and flip all bits aja_j for ljrl \le j \le r. Flipping a bit changes 00 to 11 and 11 to 00.

Let xx denote the value at special indices before any operations are applied. Find the minimum number of operations required to make all elements of the array equal to xx.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t1041 \le t \le 10^4). The description of the test cases follows.

The first line of each test case contains two integers nn and kk (1n21051 \le n \le 2 \cdot 10^5; k=1k=1) — the length of the array and the number of special indices.

The second line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (0ai10 \le a_i \le 1) — the elements of the array.

The third line contains kk integers p1,p2,,pkp_1, p_2, \ldots, p_k (1p1<p2<<pkn1 \le p_1 \lt p_2 \lt \ldots \lt p_k \le n) — the special indices. It is guaranteed that ap1=ap2==apka_{p_1} = a_{p_2} = \ldots = a_{p_k}.

It is guaranteed that the sum of nn over all test cases does not exceed 21052 \cdot 10^5.

Output

For each test case, output a single integer — the minimum number of operations required.

Note

For the first test case, you can choose the range [1,3][1, 3] and flip all the bits to get [1,0,1][1, 0, 1]. Then you can choose the range [2,2][2, 2] and flip the second bit to get [1,1,1][1, 1, 1].

For the second test case, all the bits already match the value at the special index. You do not need any operations.

Samples

4
3 1
0 1 0
2
5 1
1 1 1 1 1
1
6 1
0 1 0 1 0 1
3
17 1
0 1 1 0 1 1 0 1 0 0 1 0 1 0 1 0 1
5
2
0
4
10

在线编程 IDE

建议全屏模式获得最佳体验