Problem hidden
This problem was hidden by Editorial Board member probably because it has incorrect language version or invalid test data, or description of the problem is not clear.

POS_NOTA - Positional notations

Your task is to change number n from decimal to in base-p positional notation.

Input

The first line of the standard input contains one integer t (t<10001) which is the number of test cases.

In each of the next t lines there are two numbers: n<22*108 and p<17 (n - number in decimal, p - base in which you should print number n).

Output

For each test, print number n in base-p positional notation.

Example

Input:
7
4 5
4 3
4 2
4 4
12 16
123 10
123 13

Output:
4
11
100
10
c
123
96


Added by:Piotr Ką…kol
Date:2010-01-10
Time limit:2.854s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: SCM qobi
Resource:Positional notation

hide comments
2012-02-21 19:53:48 Mitch Schwartz
n>0
2011-01-04 16:14:07 Piotr KÄ…kol
n limit added. Thanks.
2011-01-04 13:50:30 Hallvard Norheim Bø
What is the limit on n?
2010-08-01 16:15:10 Piotr KÄ…kol
They're not too slow. They just aren't available (gawk,bc,nawk,dc,sed) but I asked to add them.

Edit: You can add other commands is this topic on SPOJ forum which aren't available.

Last edit: 2010-08-01 16:16:00
2010-08-01 14:56:58 HWK
I wrote some solutions with BASH. Either they're too slow or they don't work as against at home. Are awk or sed installed in the test-environment?
2010-04-09 22:35:54 Piotr KÄ…kol
Time limit has been changed to 10sec. ;-)

Last edit: 2010-04-25 09:20:09
2010-01-20 23:16:35 Piotr KÄ…kol
Thanks! I have changed tests after making this task and forgot to change the examples.
2010-01-20 20:04:44 .:: Pratik ::.
Output in given sample is not captial C, must be lower-case C.
2010-01-20 09:10:45 .:: Pratik ::.
Is n always an integer?
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.