Under construction

Still being built. Things may change

Spreadsheet Cell Names

Interview

Time limit1sMemory limit128 MB

Summary
Convert given row and column numbers into spreadsheet-style cell names like A1 or BC23, stopping at R0C0.
Level

Easy3 of 10

Topics
Math, String, Implementation
Solved
No attempts yet

Problem

Spreadsheet columns are named in order from the first column as A, B, ..., Z. After column Z, names use two or more letters.

For example, the 27th column is AA, the 28th is AB, the 52nd is AZ, and the 53rd is BA. After ZZ comes AAA, then AAB, and so on.

Rows use their row numbers as they are. A cell name is made by writing the column name followed by the row number. For example, the top-left cell is A1, and the cell in column 55 and row 23 is BC23.

Given several row and column numbers, write a program that prints the spreadsheet cell name for each one.

Input

The input has several lines. Each line has the form RnCm, where n is the row number and m is the column number. The ranges are 1 <= n <= 300000000 and 1 <= m <= 300000000.

The last line is R0C0; do not print anything for that line, and then terminate.

Output

For each input line before R0C0, print the spreadsheet cell name on its own line, in the same order as the input.

Examples1

  1. Example 1

    Input
    R1C1
    R3C1
    R1C3
    R299999999C26
    R52C52
    R53C17576
    R53C17602
    R0C0
    Expected output
    A1
    A3
    C1
    Z299999999
    AZ52
    YYZ53
    YZZ53