In the popular spreadsheets systems (for example, in Excel) the following numeration of columns is used. The first column has number A, the second — number B, etc. till column 26 that is marked by Z. Then there are two-letter numbers: column 27 has number AA, 28 — AB, column 52 is marked by AZ. After ZZ there follow three-letter numbers, etc.

The rows are marked by integer numbers starting with 1. The cell name is the concatenation of the column and the row numbers. For example, BC23 is the name for the cell that is in column 55, row 23. 

Sometimes another numeration system is used: RXCY, where X and Y are integer numbers, showing the column and the row numbers respectfully. For instance, R23C55 is the cell from the previous example.

Your task is to write a program that reads the given sequence of cell coordinates and produce each item written according to the rules of another numeration system.
The first line of the input contains integer number *n* (1 ≤ *n* ≤ 10<sup class="upper-index">5</sup>), the number of coordinates in the test. Then there follow *n* lines, each of them contains coordinates. All the coordinates are correct, there are no cells with the column and/or the row numbers larger than 10<sup class="upper-index">6</sup> .
2
R23C55
BC23
BC23
R23C55
1
A1
R1C1
5
R8C3
D1
R7C2
R8C9
R8C9
C8
R1C4
B7
I8
I8
4
R4C25
R90C35
AP55
X83
Y4
AI90
R55C42
R83C24
10
R50C12
R23C47
Y96
R44C13
R19C21
R95C73
BK12
R51C74
AY34
R63C25
L50
AU23
R96C25
M44
U19
BU95
R12C63
BV51
R34C51
Y63
def convert_A1_to_RXCY(cell):
    # Split the cell coordinate into column and row parts
    column, row = '', ''
    for char in cell:
        if char.isalpha():
            column += char
        else:
            row += char
    # Convert column part to integer
    col_num = 0
    for char in column:
        col_num = col_num * 26 + (ord(char) - ord('A') + 1)

    # Output in the RXCY format
    return 'R{}C{}'.format(row, col_num)


def convert_RXCY_to_A1(cell):
    # Split the cell coordinate into row and column parts
    row, column = '', ''
    num_started = False
    for char in cell:
        if char.isdigit():
            num_started = True
            row += char
        elif num_started:
            column += char

    # Convert column part to letters
    col_num = int(column)
    column_letters = ''
    while col_num > 0:
        col_num -= 1
        column_letters = chr(col_num % 26 + ord('A')) + column_letters
        col_num //= 26

    # Output in the A1 format
    return column_letters + row


# Main function to handle input and output
if __name__ == "__main__":
    n = int(input())
    for _ in range(n):
        coordinate = input().strip()
        if coordinate[0] == 'R' and 'C' in coordinate:
            # RXCY format, convert to A1
            print(convert_RXCY_to_A1(coordinate))
        else:
            # A1 format, convert to RXCY
            print(convert_A1_to_RXCY(coordinate))
