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
# LUOGU_RID: 105945841
# LC168
def num2title(n: int) -> str:
    s = ""
    while n:
        n -= 1
        s = chr(n % 26 + 65) + s
        n //= 26
    return s

# LC171
def title2num(s: str) -> int:
    n = 0
    for c in s:
        n = n * 26 + ord(c) - 64
    return n

# RxxCxx -> AAxx
def r2e(s: str) -> str:
    r, c = map(int, s[1:].split('C'))
    return num2title(c) + str(r)

# AAxx -> RxxCxx
def e2r(s: str) -> str:
    i = 0
    while s[i].isalpha(): i += 1
    return "R%sC%d" % (s[i:], title2num(s[:i]))

# whether is RxxCxx format
def rc(s: str) -> bool:
    if s[0] == 'R':
        i = s.rfind('C')
        if i > 0 and s[i - 1].isdigit():
            return True
    return False

# __main__
for _ in range(int(input())):
    s = input()
    # if s[0] == 'R': # wrong, title can be started with R
    if rc(s):
        print(r2e(s))
    else:
        print(e2r(s))