BASECVT  Base Conversion (Easy)
We want to make some baseconversion experiments. Here you can try basic methods.
Input
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_{k1}×B1^{k1}
Output
For each test case, you have to print the number N in base B2. See sample for details.
Example
Input: 1 10 100 5 5 4 3 2 1
Output: 3 < Don't forget the length of N in base B2 ;) 45 23 1
Explanations
For the lonely case, N = 5×10^{0} + 4×10^{1} + 3×10^{2} + 2×10^{3} + 1×10^{4} = 12345.
We have: N = 45×100^{0} + 23×100^{1} + 1×100^{2}. You have to print 3, the number of digits,
then the digits: 45, 23 and 1.
Constraints
0 < T <= 200 1 < B1,B2 <= 10^9 1 < k <= 1000 0 <= a_{i} < B1 , a_{k1}>0
If you find the constraints too easy, then you should try BASECONV.
The basic solution should give AC in 1.56s with Python3. (Edit 20170211 : 0.42s with new compiler)
Have fun ;)
hide comments
:.Mohib.::
20150627 00:51:27
In explaination:


Mitch Schwartz:
20140319 21:16:02
It seems my basic solution is more basic than your basic solution. :p

Added by:  Francky 
Date:  20140319 
Time limit:  60s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 
Resource:  Own Problem 