Given a natural , a basis and a natural number , we want to write in basis using exactly characters, following the next format:
If in basis has exactly digits, you only must write in basis .
If in basis has less than digits, you must add hashes on the left.
If in basis has more of digits, you must write asterisks instead of .
Your task is to write a program that, given a sequence of triplets , , , prints for each one a line following this format.
The input is a sequence of triplets , , , with , and .
For each triplet of the input, print a line according to the described format.
Strings are not allowed in this problem.
We suggest you to use a function @number_of_digits(n, b)@ that, given two natural numbers |n| and |b| with , returns the number of digits that requires the representation of |n| in basis |b|.
You must use recursion to write in basis (without the hashes).
Input
54321 10 5
4321 10 5
654321 10 5
9999 10 20
125 2 8
125 3 8
125 4 8
125 5 8
125 6 8
125 7 8
125 8 8
125 9 8
536870912 2 1
536870912 2 32
0 2 1
0 10 2
Output
54321 #4321 ***** ################9999 #1111101 ###11122 ####1331 ####1000 #####325 #####236 #####175 #####148 * ##100000000000000000000000000000 0 #0