This page is still under construction.

Parts of this page are still being built. What you see may change.

Base Conversion 2

Interview

Time limit0.5sMemory limit256 MB

Summary
Convert the decimal number N to base B, writing digits above 9 as uppercase letters.
Level

Easy2 of 10

Topics
Math, Implementation
Solved
No attempts yet

Problem

A number NN written in base 10 is given. Write a program that converts it to base BB and prints the result.

In a base above 10, some digits cannot be written with the characters 0 to 9. Those digits use uppercase letters. A is 10, B is 11, and in the same way F is 15, Y is 34, and Z is 35.

Input

The first line contains NN and BB, separated by a space. NN is a natural number no greater than one billion, and BB is an integer with 2≤B≤362 \le B \le 36.

Output

Print NN written in base BB on the first line. Write digits above 9 as uppercase letters, and do not add leading zeros.

Examples6

  1. Example 1

    Input
    60466175 36
    
    Expected output
    ZZZZZ
    
  2. Example 2

    Input
    1 2
    
    Expected output
    1
    
  3. Example 3

    Input
    1 36
    
    Expected output
    1
    
  4. Example 4

    Input
    35 36
    
    Expected output
    Z
    
  5. Example 5

    Input
    36 36
    
    Expected output
    10
    
  6. Example 6

    Input
    255 16
    
    Expected output
    FF