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.
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).
For each of the test case print the correct password.
Each character of W and A will be from ‘a’-‘z’ , ‘A’-‘Z’.
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.