#t100. 进制转换

进制转换

Base Conversion (Decimal to R-ary)

Problem Description

Xiaomei just learned hexadecimal and found it interesting. She wonders if there are even larger bases. In hexadecimal, A represents 1010 and F represents 1515. If we extend it so that Z represents 3535, can't we represent base-3636 numbers?

So you need to help her write a program that converts a decimal number to base RR (2≤R≤362 \le R \le 36).

Input Format

Two lines of input. The first line contains a positive integer NN. The second line contains a positive integer RR. It is guaranteed that 1≤N≤1061 \le N \le 10^6.

Output Format

One line: the base-RR representation of NN.

Sample Input

123
25

Sample Output

4N

Sample Explanation

The process of converting the decimal number 123123 to base 2525 is as follows:

  1. 123123 divided by 2525 gives quotient 44 and remainder 2323.
  2. The remainder 2323 maps to the character N under the extended rule (A is 1010, and so on, N is 2323).
  3. The quotient 44 is kept as is, since 4<254 < 25.
  4. Concatenate the results from the last quotient to the first remainder, giving 4N.

So the output is 4N.

Constraints

For all data, 2≤R≤362 \le R \le 36, 1≤N≤1061 \le N \le 10^6.