Save Your Life
Submissions: 386   Accuracy:

19.43%

  Difficulty: Medium   Marks: 4

Shabnam being a secret detective has all the information about your crimes. There has been an ongoing trail whose result is to be decided today, but Shabnam is currently out and all the proofs of your crime is locked in her house with a secret password which only she knows. If all the evidences are not presented today you may walk free but if they are brought before your trail is over you will be sentenced to death.

Shabnam knows that you will try hard to save yourself and get out the password somehow before the police do. So Shabnam despite of sending the password directly send it in an encoded form. Now to save yourself you need to decode the password before the police do.

Shabnam sends a long word W which includes the password as its substring. The password will be the substring which has the sum of the ASCII values of its each character of as maximum. Shabnam knows you are intelligent enough to decode this so she redefines ASCII values of some character which she chooses.

Your task is to save your life.

Input

The first line of the test case contains an integer T, denoting number of test cases.

The first line of each test case contains a string W, denoting the long word which contains substring as the password. The second line contains an integer N denoting the number of characters whose ASCII value Shabnam wishes to redefine. The third line contains N space separated characters A(i). The fourth line contains N space separated integers B(i).

B(i) denotes the redefined ASCII value of the character A(i).

Output:

For each of the test case print the correct password.

Constraints:

1<=T<=100000

1<=|W|<=100

1<=N<=10

-1000<=B(i)<=1000

Each character of W and A will be from ‘a’-‘z’ , ‘A’-‘Z’.

Example

Input:

1

abcde

1

c

-1000

Output:

de

** For More Input/Output Examples Use 'Expected Output' option **

Author: ShivamKD


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.