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
# Libraries

import sys
from math import *
from queue import PriorityQueue

# Definitions
mod = pow(10,9)+7
e = pow(10,-6)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# sys.setrecursionlimit(10**6)

#Input forms

def imap(): # Multiple numbers input
    return map(int,input().split())

def ilist(): # List input 
    return list(map(int,input().split()))

def ilgraph(n,m): # Graph input as Adjacency List

    l = [[]for i in range(n+1)]
    for i in range(m):
        x,y = imap()
        l[x].append(y)
        l[y].append(x)
    return l

def iagraph(n,m): # Graph input as Adjacency Matrix
    l = [[0 for i in range(n+1)]for i in range(n+1)]
    for i in range(m):
        x,y = imap()
        l[x][y] = 1
        l[y][x] = 1
    return l

# Common functions

def freq(l): # Returns count of a number in a list/string // O(nlog(n)) //
    d = {}
    for i in l:
        d[i] = d.get(i,0)+1
    return d

# Math and number Theory :

def is_pow2(x): #Checks if a number is a power of 2 // O(1) //
    return max(1-(x&(x-1)),0)

def lgcd(l): # Returns gcd of a list // O(nlog(n)) //
    a = 0
    for i in l:
        a = gcd(a,i)
    return a

def SieveOfEratosthenes(num): # Returns an array with Prime numbers upto num // O(nlog(log(n))) //
    prime = [True for i in range(num+1)]
    Highest_Prime = [0 for i in range(num+1)] # Returns an array with the highest prime factor of each i between 0 and Num 
    Lowest_Prime = [0 for i in range(num+1)] # Returns an array with the lowest prime factor of each i between 0 and Num
    prime[0] = prime[1] = False
    p = 2
    while (p <= num):
        if (prime[p] == True):
            Lowest_Prime[p] = p
            Highest_Prime[p] = p
            for i in range(2*p, num+1, p):
                prime[i] = False
                Highest_Prime[i] = p
                if Lowest_Prime[i] == 0:
                    Lowest_Prime[i] = p
        p += 1
    # print(prime,'\n',Highest_Prime,'\n',Lowest_Prime)         #Checker
    # return Lowest_Prime
    # return Highest_Prime
    return prime

def PrimeFactors(num,Prime_array):# Returns a dictionary with prime factors mapped with their respective powers // O(nlogn) //
    
    # COmplexity is O(logn) for this code, but this requires that u have a Prime array which could be highest or lowest prime which can be calculated from the prev Sieve of Erastothenes) hence over complexity is O(nlogn)
    
    d = {}
    while num != 1: 
        x = Prime_array[num]
        d[x] = d.get(x,0)+1
        num//=x
    return d

# Binary Arithmetic 

def bin_left(p,x): #Returns the index of max element less than x and -1 if all elements r greater than x // O(logn) //
    n = len(p)
    l,r = 0,n-1
    if p[0]>x:
        return -1
    while l<=r:
        mid = (l+r)//2
        if p[mid] <= x:
            if mid != n-1:
                if p[mid+1]>x:
                    break
                else:
                    l = mid+1
            else:
                mid = n-1
                break
        else:
            r = mid-1
    return mid

    for i in range(100):
        mid = (l+r)/2
        if f(mid)>f(mid+e):
            l = mid+e
        else:
            if f(mid-e)>f(mid):
                break
            else:
                r = mid-e
    return mid

def bin_right(p,x): #Returns the index of min element greater than x and n if all elements r less than x // O(logn) //
    n = len(p)
    l,r = 0,n-1
    if p[-1]<x:
        return n

    while l<=r:
        mid = (l+r)//2
        if p[mid] >= x:
            if mid != 0:
                if p[mid-1]<x:
                    break
                else:
                    r = mid-1
            else:
                mid = 0
                break
        else:
            l = mid+1
    return mid

def bin_sqrt(x): # Returns floor of sqrt // O(logx) //
    if x == 0 or x == 1:
        return x
    l = 1
    r = x
    while l<=r:
        mid = (l+r)/2
        y = mid*mid
        if y>x:
            r = mid-1
        elif y == x:
            return mid
        else:
            if ((mid+1)*(mid+1))>x:
                return mid
            else:
                l = mid+1
    
def bin_exp(a,b,mod): #Returns (a^b) mod m where 0 <= a,b <= 10^18 // O(log(b)) //
    ans = 1
    while b>0:
        if b&1:
            ans = (ans*a)% mod
        a = (a*a)%mod
        b >>= 1
    return ans

def bin_to_dec(s): # Takes a binary string and returns its decimal value

    x = 0
    n = len(s)
    for i in range(n):
        x += int(s[n-i-1])*(2**i)
    return x

# Graph Algos

def dfs(graph,ver,vis): # DFS on a graph
    vis[ver] = True
    print(ver,end = ' ')
    for child in graph[ver]:
        if vis[child]:
            continue
        dfs(graph,child,vis)
    


# Starting off; 

t = int(input())
for _ in range(t):
    s = input()
    n = len(s)
    if s[0] != 'R':
        r = 0
        for i in range(n):
            if s[i].isalpha():
                r *= 26
                r += ord(s[i])-ord('A')+1
            else:
                break
        print('R'+str(s[i:])+'C'+str(r))
    else:
        c = 0
        for i in range(n-1):
            if s[i].isalpha() and s[i+1].isdigit():
                c += 1
        if c == 1:
            r = 0
            for i in range(n):
                if s[i].isalpha():
                    r *= 26
                    r += ord(s[i])-ord('A')+1
                else:
                    break
            print('R'+str(s[i:])+'C'+str(r))
        else:
            l = s[1:].split('C')
            # print(l)
            r,t = int(l[1]),l[0]
            q = ''
            while (r>0):
                x = (r%26)+ord('A')-1
                if r%26 == 0:
                    r = r//26-1
                    x += 26
                else:
                    r//=26
                q+=chr(x)
            print(q[::-1]+t)



###################################################### By Shri ##############################################################
