Problem: Polycarp wrote on the board a string containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input.
After that, he erased some letters from the string , and he rewrote the remaining letters in any order. As a result, he got some new string . You have to find it with some additional information.
Suppose that the string has length and the characters are numbered from left to right from to . You are given a sequence of integers: , where is the sum of the distances from the index to all such indices that (consider that 'a'<'b'<...<'z'). In other words, to calculate , Polycarp finds all such indices that the index contains a letter that is later in the alphabet than and sums all the values .
For example, if = "abzb", then:
- since ='a', all other indices contain letters which are later in the alphabet, that is: ;
- since ='b', only the index contains the letter, which is later in the alphabet, that is: ;
- since ='z', then there are no indexes such that , thus ;
- since ='b', only the index contains the letter, which is later in the alphabet, that is: .
Thus, if = "abzb", then .
Given the string and the array , find any possible string for which the following two requirements are fulfilled simultaneously:
- is obtained from by erasing some letters (possibly zero) and then writing the rest in any order;
- the array, constructed from the string according to the rules above, equals to the array specified in the input data.
Input Format: The first line contains an integer () — the number of test cases in the test. Then test cases follow.
Each test case consists of three lines:
- the first line contains string , which has a length from to and consists of lowercase English letters;
- the second line contains positive integer (), where is the length of the string , and is the length of the array ;
- the third line contains the integers ().
It is guaranteed that in each test case an answer exists.
Output Format: Output lines: the -th of them should contain the answer (string ) to the -th test case. It is guaranteed that an answer to each test case exists. If there are several answers, output any.
Note: In the first test case, such strings are suitable: "aac', "aab".
In the second test case, such trings are suitable: "a", "b", "c".
In the third test case, only the string equals to "aba" is suitable, but the character 'b' can be from the second or third position.