SP19133 BASECONV - Base Conversion

Description

Leo didn't do all the job in his [last problem](http://www.spoj.com/problems/DUKKAR2/), somebody gave him the numbers in a convenient base. It was the bottleneck of the problem... Now your task is to do this job.

Input Format

The first line of input contains three integers **_T_**, the number of test cases, **_B1_**, the first base, **_B2_**, the second base. Follow 2×**_T_** lines. For each test case, on the first line your are given one integer **_k_**. On the second line you are given **_k_** integers : the digits of **_N_** in base **_B1_**. **_N = a $ _{0} $ ×B1 $ ^{0} $ + ... + a $ _{i} $ ×B1 $ ^{i} $ + ... + a $ _{k-1} $ ×B1 $ ^{k-1} $_**

Output Format

For each test case, you have to print the number **_N_** in base **_B2_**. See sample for details.