beecrowd | 2820
# Bruna's Digits

**Timelimit: 3**

By Giovanna Kobus Conrado, Universidade de São Paulo Brazil

Bruna is learning to count. She already knows d digits. Her brother, Carlos, told her that she can't even form n distinct numbers using those digits only. Bruna, to prove that he is wrong, will write the n smallest numbers that she can make using only the digits she knows in a sheet of paper, but she doesn't know when to stop. Can you help her wit that task?

The first line of input consists of a number **t **(**t**=100) , the number of test cases.

Each case starts with an integer** d** (2<=**d**<=9): the number of digits Bruna has already learned.

The following line will contain d integers **v**** _{i}** (1<=

The last line of each case will be the number **n **(1<=**n**<=10^{18}).

For each case, print the n^{th} smallest number that can be made using the digits Bruna knows.

Input Sample | Output Sample |

2 2 1 3 4 3 9 7 8 5 |
13 78 |