Number Base Conversion

No attempts yetTime limit1sMemory limit128 MB

Problem

Write a program that converts a number written in one base into the same number written in another base. There are 62 possible digits:

{ 0-9, A-Z, a-z }

Hint: if you chain base conversions, feeding the output of one conversion in as the input to the next, then when you return to the original base you should recover the original number.

Input

The first line contains a single positive integer: the number of lines that follow.

Each following line contains a (decimal) input base, a (decimal) output base, and a number written in the input base, separated by spaces. Both the input base and the output base are in the range from 2 to 62.

The digit values are: 09 have their usual meanings 0 through 9, and A = 10, B = 11, …, Z = 35, a = 36, b = 37, …, z = 61.

Output

For each base conversion, print three lines.

  1. The first line is the input base (in decimal), a space, then the input number exactly as it was given.
  2. The second line is the output base (in decimal), a space, then the same number expressed in the output base.
  3. The third line is blank.