#P1986C. Update Queries

    ID: 10652 Type: RemoteJudge 2000ms 256MiB Tried: 0 Accepted: 0 Difficulty: 3 Uploaded By: Tags>data structuresgreedysortings*1100

Update Queries

Description

Let's consider the following simple problem. You are given a string ss of length nn, consisting of lowercase Latin letters, as well as an array of indices indind of length mm (1indin1 \leq ind_i \leq n) and a string cc of length mm, consisting of lowercase Latin letters. Then, in order, you perform the update operations, namely, during the ii-th operation, you set sindi=cis_{ind_i} = c_i. Note that you perform all mm operations from the first to the last.

Of course, if you change the order of indices in the array indind and/or the order of letters in the string cc, you can get different results. Find the lexicographically smallest string ss that can be obtained after mm update operations, if you can rearrange the indices in the array indind and the letters in the string cc as you like.

A string aa is lexicographically less than a string bb if and only if one of the following conditions is met:

  • aa is a prefix of bb, but aba \neq b;
  • in the first position where aa and bb differ, the symbol in string aa is earlier in the alphabet than the corresponding symbol in string bb.

Each test consists of several sets of input data. The first line contains a single integer tt (1t1041 \leq t \leq 10^4) — the number of sets of input data. Then follows their description.

The first line of each set of input data contains two integers nn and mm (1n,m1051 \leq n, m \leq 10^5) — the length of the string ss and the number of updates.

The second line of each set of input data contains a string ss of length nn, consisting of lowercase Latin letters.

The third line of each set of input data contains mm integers ind1,ind2,,indmind_1, ind_2, \ldots, ind_m (1indin1 \leq ind_i \leq n) — the array of indices indind.

The fourth line of each set of input data contains a string cc of length mm, consisting of lowercase Latin letters.

It is guaranteed that the sum of nn over all sets of input data does not exceed 21052 \cdot 10^5. Similarly, the sum of mm over all sets of input data does not exceed 21052 \cdot 10^5.

For each set of input data, output the lexicographically smallest string ss that can be obtained by rearranging the indices in the array indind and the letters in the string cc as you like.

Input

Each test consists of several sets of input data. The first line contains a single integer tt (1t1041 \leq t \leq 10^4) — the number of sets of input data. Then follows their description.

The first line of each set of input data contains two integers nn and mm (1n,m1051 \leq n, m \leq 10^5) — the length of the string ss and the number of updates.

The second line of each set of input data contains a string ss of length nn, consisting of lowercase Latin letters.

The third line of each set of input data contains mm integers ind1,ind2,,indmind_1, ind_2, \ldots, ind_m (1indin1 \leq ind_i \leq n) — the array of indices indind.

The fourth line of each set of input data contains a string cc of length mm, consisting of lowercase Latin letters.

It is guaranteed that the sum of nn over all sets of input data does not exceed 21052 \cdot 10^5. Similarly, the sum of mm over all sets of input data does not exceed 21052 \cdot 10^5.

Output

For each set of input data, output the lexicographically smallest string ss that can be obtained by rearranging the indices in the array indind and the letters in the string cc as you like.

Sample Input 1

4
1 2
a
1 1
cb
4 4
meow
1 2 1 4
zcwz
7 4
abacaba
1 3 5 7
damn
7 10
traktor
7 6 5 4 3 2 1 6 4 2
codeforces

Sample Output 1

b
cwoz
abdcmbn
ccdeefo

Note

In the first set of input data, you can leave the array indind and the string cc unchanged and simply perform all operations in that order.

In the second set of input data, you can set the array ind=[1,1,4,2]ind = [1, 1, 4, 2] and c=c = "zczw". Then the string ss will change as follows: meowzeowceowceozcwozmeow \rightarrow zeow \rightarrow ceow \rightarrow ceoz \rightarrow cwoz.

In the third set of input data, you can leave the array indind unchanged and set c=c = "admn". Then the string ss will change as follows: abacabaabacabaabdcabaabdcmbaabdcmbnabacaba \rightarrow abacaba \rightarrow abdcaba \rightarrow abdcmba \rightarrow abdcmbn.