#P1891B. Deja Vu

    ID: 10135 Type: RemoteJudge 2000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>brute forcemathsortings

Deja Vu

Description

You are given an array aa of length nn, consisting of positive integers, and an array xx of length qq, also consisting of positive integers.

There are qq modification. On the ii-th modification (1iq1 \leq i \leq q), for each jj (1jn1 \leq j \leq n), such that aja_j is divisible by 2xi2^{x_i}, you add 2xi12^{x_i-1} to aja_j. Note that xix_i (1xi301 \leq x_i \leq 30) is a positive integer not exceeding 30.

After all modification queries, you need to output the final array.

The first line contains a single integer tt (1t1041 \leq t \leq 10^4) — the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers nn and qq (1n,q1051 \leq n, q \leq 10^5) —the length of the array aa and the number of queries respectively.

The second line of each test case contains nn integers a1,a2,a3,,ana_1, a_2, a_3, \ldots, a_n — the elements of the array aa (1ai1091 \leq a_i \leq 10^9).

The third line of each test case contains qq integers x1,x2,x3,,xqx_1, x_2, x_3, \ldots, x_q — the elements of the array xx (1xi301 \leq x_i \leq 30), which are the modification queries.

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

For each test case, output the array after all of the modification queries.

Input

The first line contains a single integer tt (1t1041 \leq t \leq 10^4) — the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers nn and qq (1n,q1051 \leq n, q \leq 10^5) —the length of the array aa and the number of queries respectively.

The second line of each test case contains nn integers a1,a2,a3,,ana_1, a_2, a_3, \ldots, a_n — the elements of the array aa (1ai1091 \leq a_i \leq 10^9).

The third line of each test case contains qq integers x1,x2,x3,,xqx_1, x_2, x_3, \ldots, x_q — the elements of the array xx (1xi301 \leq x_i \leq 30), which are the modification queries.

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

Output

For each test case, output the array after all of the modification queries.

Sample Input 1

4
5 3
1 2 3 4 4
2 3 4
7 3
7 8 12 36 48 6 3
10 4 2
5 4
2 2 2 2 2
1 1 1 1
5 5
1 2 4 8 16
5 2 3 4 1

Sample Output 1

1 2 3 6 6 
7 10 14 38 58 6 3 
3 3 3 3 3 
1 3 7 11 19

Note

In the first test case, the first query will add 22 to the integers in positions 44 and 55. After this addition, the array would be [1,2,3,6,6][1, 2, 3, 6, 6]. Other operations will not modify the array.

In the second test case, the first modification query does not change the array. The second modification query will add 88 to the integer in position 55, so that the array would look like this: [7,8,12,36,56,6,3][7, 8, 12, 36, 56, 6, 3]. The third modification query will add 22 to the integers in positions 2,32, 3, 44 and 55. The array would then look like this: [7,10,14,38,58,6,3][7, 10, 14, 38, 58, 6, 3].