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 ≤ 105), 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 106 .

Write n lines, each line should contain a cell coordinates in the other numeration system.

'use strict';process.stdin.resume();process.stdin.setEncoding('utf-8');
let _iS = '',_cL = 0; process.stdin.on('data', _iSi => _iS += _iSi);
process.stdin.on('end', _ => {_iS = _iS.trim().split('\n').map(s => s.trim());main()});
const readline = () => _iS[_cL++];
//////////

const main = () => {
    const count = parseInt(readline());

    for(let i = 0; i < count; i++){
        console.log(transform(readline()));
    }
}

const transform = string => {
    if(/^R[0-9]+C[0-9]+/.test(string)) {
        const args = string.split('C');
        const rowNumber = parseInt(args[0].slice(1));
        const colNumber = parseInt(args[1]);

        const colCodes = [];
        let quotient = colNumber, remainder = 0;
        while(quotient >= 1) {
            remainder = quotient % 26;
            quotient /= 26;

            if(remainder < 1) {
                quotient -= 1;
                colCodes.push(26);
            } else {
                colCodes.push(remainder | 0);
            }
        }

        const colCode = colCodes.map(code => String.fromCharCode(code + 64)).reverse().join('')
        return `${colCode}${rowNumber}`;
    } else {
        const columnCode = string.replace(/[0-9]/g, '');
        const rowNumber = string.replace(/[A-Z]/g, '');

        const base26 = columnCode.split('').map(char =>
            (char.charCodeAt(0) - 64));
        const base10 = base26.reverse().map((v, i) => v * (26 ** i)).reduce((a, b) => a + b);

        return `R${rowNumber}C${base10}`;
    }
};

  var count = readline();
  while(count--){
    s = readline();
    m = /^R(\d+)C(\d+)/.exec(s);
    if(m){
      print( toChar(m[2]) + m[1]);
    }else{
      m = /^([A-Z]+)(\d+)/.exec(s);
      print( 'R' + m[2] + 'C' + toNum( m[1]) );
    }

  }

  function toChar(num){
    var ret = '';
    var t
    while(num>0){
      var u = num % 26;
      num = Math.floor( num/26 );
      if(!u){
        u = 26
        num--;
      }
      ret = String.fromCharCode(u+64) + ret;
    }
    return ret;

  }
  function toNum(char){
	var l = char.length;
	var ret = 0;
	var t = 1;
	while(l--){
		ret += ( char.charCodeAt(l)-64 ) * t;
		t *= 26
	}
	return ret;
}

function lc(l) {
  return l.charCodeAt(0) - 64;
}

function cl(c) {
  return String.fromCharCode(c + 64);
}

function lton(str){
  var r = 0, i = 0, l = str.length;
  for (; i < l; i++) {
    r += (i === 0 ? 1 : Math.pow(26, i)) * lc(str[l - i - 1]);
  }
  return r;
}

function ntol(n) {
  var d = n, res = '';
  while (d > 0) {
    var ost = d % 26;
    //console.log(d, ost);
    d = Math.floor(d / 26) - (!ost ? 1 : 0);
    res = cl(ost || 26) + res;
  }
  return res;
}

function parse(str) {
  var m = str.match(/^R(\d+)C(\d+)$/i);
  if (m) {
    return ntol(m[2])+m[1];
  } else {
    m = str.match(/^([A-Z]+)(\d+)$/);
    return 'R'+m[2]+'C'+lton(m[1]);
  }
}

var n = +readline();

for (var i = 0; i < n; i++) {
  print(parse(readline()));
}

var pos = readline();
var array = [];
var ascii = 64;
var num26 = 26;

for (var i = 0; i < pos; i++) {
    array.push(readline());
}

for (var i = 0; i < array.length; i++) {
    var text = array[i];
    var pattern = /R[(0-9)]{1,100}C[(0-9)]{1,100}/;
    if (pattern.test(text)) {
        var row = 0;
        var col = 0;
        var separator = 0;
        for (var j = 0; j < text.length; j++) {
            if (text[j] == 'C') {
                separator = j;
            }
        }

        var row = parseInt(text.substring(0, separator).replace(/[^0-9]/g, ''));
        var col = parseInt(text.substring(separator, text.length).replace(/[^0-9]/g, ''));
        var text = '';
        while(col > 0) {
            if (col <= num26) break;

            var remain = col % num26;
            if (remain === 0) {
                col = Math.floor(col / num26) - 1;
                text = 'Z' + text;
            } else {
                col = Math.floor(col / num26);
                var char = String.fromCharCode(remain + ascii);
                text = char + text;
            }
        }

        if (col === 0) {
            col = 26;
        }

        var first = String.fromCharCode(col + ascii);
        text = first + text;

        var converted = text + row;
        print(converted);
    } else {
        var separator = 0;
        for (var j = 0; j < text.length; j++) {
            var number = parseInt(text[j]);
            if (number >= 0 && number <= 9) {
                separator = j;
                break;
            }
        }

        var row = parseInt(text.substring(separator, text.length));
        var col = text.substring(0, separator);
        var colNum = 0;
        col = col.split('').reverse();
        for (var j = 0; j < col.length; j++) {
            var char = col[j].toUpperCase().charCodeAt(0) - ascii;
            if (j === 0) {
                colNum += char;
            } else {
                colNum += (Math.pow(num26, j) * char);
            }
        }

        var converted = 'R' + row + 'C' + colNum;
        print(converted);
    }
}

function main() {
  const count = readline();
  for (var i = 0; i < count; i++) {
      var view = readline();
      if (isRowColumnView(view)) {
          print(changeViewToExcel(view));
      } else {
          print(changeViewToCR(view));
      }
  }
}

main();

function main() {
    const count = readline();
    for (var i = 0; i < count; i++) {
        var view = readline();
        if (isRowColumnView(view)) {
            print(changeViewToExcel(view));
        } else {
            print(changeViewToCR(view));
        }
    }
}

function isRowColumnView(str) {
    return /R\d+C\d+/i.test(str);
  }

  function changeViewToCR(str) {
    var indexOfNumber = 0;
    var numberArr = [];
    var column;
    for (var i = 0; i < str.length; i++) {
        var char = str[i];
        if (isNaN(char)) {
            numberArr.push(char.charCodeAt(0) - 64);
        } else {
            indexOfNumber = i;
            break;
        }
    }
    column = numberArr.reduce( (col, elem, i) => {
        return col += elem * Math.pow(26, numberArr.length - 1 - i);
    }, 0)
    return `R${str.slice(indexOfNumber)}C${column}`;
  }

  function changeViewToExcel(str) {
    var indexOfC = str.indexOf("C");
    var dividend = +str.slice(indexOfC + 1);
    var columnName = "";
    var module;

    while (dividend > 0)
    {
        module = (dividend - 1) % 26;
        columnName = String.fromCharCode(65 + module) + columnName;
        dividend = parseInt(((dividend - module) / 26));
    }

    var row = str.slice(1, indexOfC);
    return `${columnName}${row}`;
  }

  function getBaseLog(x, y) {
    return Math.log(y) / Math.log(x);
  }

function main(){
    var n=readline();
    var numration=[];
    var firstnumRule=/R\d+C\d+/;
    //var input =["R23C55","BC23"];
    for(var i=0;i<n;i++){
        numration[i]=readline();
    }
    for(var j=0;j<n;j++){
        var result='';
        if(firstnumRule.test(numration[j])){
            //R12C12型
            var tmpnum=numration[j].match(/\d+/g);
            var row1=tmpnum[0];
            var col1=tmpnum[1];
            var resultcoltmp='';
            var resultcol='';
            while(col1){
                resultcoltmp=resultcoltmp+String.fromCharCode((col1-1)%26+65);
                col1=parseInt((col1-1)/26);
            }
            for(var r=resultcoltmp.length- 1;r>=0;r--){
                resultcol=resultcol+resultcoltmp[r];
            }
            result=resultcol+row1;
        }else{
            var col2=numration[j].match(/[A-Z]+/g) + '';
            var row2=numration[j].match(/\d+/g);
            var resultcol2=0;
            //AB123123型
            for(var g=0;g<col2.length;g++){
                //resultcol2+=(col2[g].charCodeAt()-65)*Math.pow(26,count);
                resultcol2= 26*resultcol2 +(col2[g].charCodeAt()-'A'.charCodeAt())+1;
            }
            result='R'+row2+'C'+resultcol2;
        }
        print(result);
        //console.log(result);
    }
}
main();

function codeToValue(str){
	var total = 0;
	for(var i in str){
		var inx = (str.length-1)-i;
		var char = str[inx].toUpperCase();
		var code = char.charCodeAt(0)-64;
		var place = Math.pow(26, i);
		var value = place * code;
		total += value;
	}
	return total;
}

var valueToCode = function(value){

	var i = 1;
	var code = [];

	do {

		var lv = Math.pow(26, i);

		var mod = value % lv;

		var digit = Math.floor(mod/Math.pow(26, i-1));
		code.unshift(digit);

		i++;

	}while( value >= lv );

	var validate = function(i){
		if(code[i] == 0 && i > 0){
			validate(i-1);
			code[i-1]--;
			code[i] = 26;
		}
	}

	for(var i=code.length-1;i>0;i--){
		validate(i);
	}

	while(code[0]==0)
		code.shift();

	return code.map(function(e){ return String.fromCharCode(64+e) }).join("");
}

var convert = function(v){

	var p1 = /R([0-9]+)C([0-9]+)/;
	var p2 = /([A-Z]+)([0-9]+)/;

	if(v.match(p1))
	{
		//R1C1 --> A
		var row = v.replace(p1, "$1");
		var column = valueToCode(v.replace(p1, "$2"));
		return column+row;
	}
	else {
		//A23 -> R1C1
		var column =  codeToValue(v.replace(p2, "$1"));
		var row = v.replace(p2, "$2");
		return ["R", row, "C", column].join("");
	}
}

var numData = readline();
for(var i=0;i<numData;i++){
	var v	= readline();
	print(convert(v));
}

function NumberToString(n)
{
    var s="";
    n=Number(n);
    while(n>0)
    {
        s=String.fromCharCode((n+25)%26+'A'.charCodeAt())+s;
        n=Math.floor((n-1)/26);
    }
    return s;
}
function StringToNumber(s)
{
    var x=0;
    for(var i=0;i<s.length;i++)
        x=x*26+s[i].charCodeAt()-'A'.charCodeAt()+1;
    return String(x);
}

function main()
{
    var n = Number(readline());
    for(var i=0;i<n;i++)
    {
        var s=readline();
        var r;
        r=s.match(/R(\d+)C(\d+)/);
        if(r)
        {
            print(NumberToString(r[2])+r[1]);
        }
        else
        {
            r=s.match(/([A-Z]+)(\d+)/);
            if(r)
            {
                print("R"+r[2]+"C"+StringToNumber(r[1]));
            }
        }
    }

}

main();

var A = 'A'.charCodeAt(0);
var Z = 'Z'.charCodeAt(0);
var D = Z - A + 1;

function toABS (n) {
	if (n >= D) {
		return toABS(Math.floor(n / D) - 1) + toABS(n % D);
	} else {
		return String.fromCharCode(A + n);
	}
}

function to123 (s) {
	var n = 0;
	for (var i = 0; i < s.length; i++) {
		n += (s.charCodeAt(i) - A + 1) * Math.pow(D, s.length - i - 1);
	}
	return n;
}

;(function () {

	var n = +readline();

	while (n--) {
		var s = readline();
		var r = /^R(\d+)C(\d+)/.exec(s);

		if (r) {
			print(toABS((+r[2]) - 1) + r[1]);
		} else {
			r = /^([A-Z]+)([0-9]+)/.exec(s);
			print('R' + r[2] + 'C' + to123(r[1]));
		}
	}

}).call(this);

  readline()
  var line
  while(line = readline()) {
    var codeOf2 = line[1].charCodeAt()
    var ioC = line.indexOf('C')
    print((codeOf2 >= 48 && codeOf2 <= 57 && ioC >= 2 ? sf : fs)(line))
  }

  function cn (c) {
    return c.charCodeAt() - 64
  }

  function nc (n) {
    return String.fromCharCode(n + 64)
  }

  function fs (f) {
    for (var i = 0; i < f.length; i++) {
      var cc = f[i].charCodeAt()
      if (cc >= 48 && cc <=57) break
    }
    var c = f.slice(0, i)
    var r = f.slice(i)
    c = c.split('').reverse().reduce(function (a, l, i) {return a + cn(l) * Math.pow(26, i)}, 0)
    return 'R' + r + 'C' + c
  }

  function sf (s) {
    var ci = s.indexOf('C')
    var r = s.slice(1, ci)
    var c = +s.slice(ci + 1)
    var cn = ''
    while (c) {
      var cd = c % 26
      if (cd == 0) {
        cd = 26
        c -= 26
      }
      cn = nc(cd) + cn
      c = c / 26 | 0
    }
    return cn + r
  }

var n = parseInt(readline());
const pattern = /([A-Z]+\d+){2}/;
const del1 = /R(\d+)C(\d+)/, del2 = /([A-Z]+)(\d+)/;
while(n--) {
    var line = readline();
    if(line.match(pattern)){
        var data = del1.exec(line);
        print(toStr(data[2]) + data[1]);
    }
    else {
        var data = del2.exec(line);
        print(`R${data[2]}C${toNum(data[1])}`);
    }
}

function toStr(num) {
    var ret = '';
    var t
    while(num>0){
      var u = num % 26;
      num = parseInt( num/26 );
      if(!u){
        u = 26
        num--;
      }
      ret = String.fromCharCode(u+64) + ret;
    }
    return ret;
}

function toNum(str) {
    var res = 0;
	for(var i = 0; i < str.length; i++) {
	    res += (str.charCodeAt(i) - 64) * Math.pow(26, str.length - i - 1);
	}
	return res;
}

var n = readline(),
    coord,
    match;

while (n--) {
    coord = readline();

    match = coord.match(/^([A-Z]*)(\d*)$/);
    if (match) {
        print('R'+ match[2] + 'C' + toNumber(match[1]));
    } else {
        match = coord.match(/^R(\d*)C(\d*)$/);
        print(toChar(parseInt(match[2])) + match[1]);
    }
}

function toNumber(str) {
    var l = str.length,
        ret = 0,
        mul = 1;

    while (l--) {
        ret += mul * (str.charCodeAt(l) - 64);
        mul *= 26;
    }

    return ret;
}

function toChar(num) {
    var ret = '';

    while (num > 0) {
        c = num % 26;
        num = Math.floor(num/26);

        if (!c) {
            c = 26;
            num--;
        }
        ret = String.fromCharCode(c + 64) + ret;
    }

    return ret;
}

const strSettings=readline().trim();
const n=Number(strSettings);
const rexRXCY=new RegExp('R[0-9]+C[0-9]+');
var str='';
var row=0;
var col=0;
var i=0;
var arr=[];
var str2='';

function ColumnNumber(strColumn){   // Convert column name to number
    const strLetters='ABCDEFGHIJKLMNOPQRSTUVWXYZ';
    var intColumn=strLetters.search(strColumn[0])+1;
    for (var j=1;j<strColumn.length;j++){
        intColumn=intColumn*26;
        intColumn=intColumn+strLetters.search(strColumn[j])+1;
    }
    return intColumn;
}

function ColumnName(intColumn) {    // Convert column number to name
    const strLetters='ABCDEFGHIJKLMNOPQRSTUVWXYZ';
    var strColumn='';
    var intRemainder=0;
    do {
       intRemainder=intColumn%26;
       if (intRemainder===0){
           intRemainder=26;
       }
       strColumn=strLetters[intRemainder-1]+strColumn;
       intColumn=intColumn-intRemainder;
       intColumn=intColumn/26;
    }
    while (intColumn>0);
    return strColumn;
}

for (i=1;i<=n;i++) {
    str=readline();
    if (str.search(rexRXCY)>=0){    // RXCY format
        //print('str:'+str);
        arr=str.split(/[A-Z]/);
        row=Number(arr[1]);
        col=Number(arr[2]);
        print(ColumnName(col)+String(row));
    } else {                        // ColRow format
        col=ColumnNumber(str.split(/[0-9]+/)[0]);
        row=Number(String(str.match('[0-9]+')));
        print('R'+String(row)+'C'+String(col));
    }
}

function typeOf(cell) {
    if (cell[0] === 'R') {
        if (isNaN(cell[1])) {
            return 1;
        } else {
            if (cell.indexOf("C") !== -1)
                return 2;
            else {
                return 1;
            }
        }
    } else {
        return 1;
    }
}

function convert_2_to_1(cell) {
    'use strict';
    let row = "";
    let column = "";
    let stringColumn = "";
    let i = 1;

    while (cell[i] !== 'C')
        row += cell[i++];

    i++;

    while (i < cell.length)
        column += cell[i++];

    column = Number(column);

    while (column !== 0) {
        let mod = column % 26;
        if (mod === 0){
            stringColumn = String.fromCharCode(90) + stringColumn;
            column -= 26;
        }
        else
            stringColumn = String.fromCharCode(64 + mod) + stringColumn;

        column = Math.floor(column / 26);
    }

    return stringColumn + row.toString();
}

function convert_1_to_2(cell) {
    'use strict';
    let i = 0;
    let row = "";
    let column = "";
    let columnBase10 = 0;
    let columnBase26 = [];
    let result = "";

    while (isNaN(cell[i])) {
        let code = cell.charCodeAt(i);
        columnBase26.push(code - 64);
        i++;
    }

    columnBase26.map((item, index, arr) => {
        columnBase10 += item * Math.pow(26, arr.length - index - 1);
    });

    column = columnBase10.toString();

    while (i < cell.length) {
        row += (cell[i]);
        i++;
    }

    result = "R" + row + "C" + column;
    return result;
}

var testNumber = parseInt(readline());

while(testNumber !== 0){
    var cell = readline();
    if(typeOf(cell) === 1)
    {
        print(convert_1_to_2(cell));
    }
    else{
        print(convert_2_to_1(cell));
    }

    testNumber--;
}

function main() {

	var n = parseInt(readline());
	var coordinates;
    for (var i=0; i < n; i++) {
    	coordinates = readline();

    	var dust = /^R(\d+)C(\d+)$/.exec(coordinates);
    	if (dust) {
    		print(toChar(dust[2]) + dust[1]);
    	} else {
    		dust = /^([A-Z]+)(\d+)$/.exec(coordinates);
    		print("R" + dust[2] + "C" + toNum(dust[1]));
    	}

    }

}
function toChar(num) {
	var a = num;
	var b;
	var r = "";
	while (a!=0) {
		b = a%26;
		if (b != 0) {
			r = String.fromCharCode(b + 64) + r;
		} else {
			r = "Z" + r;
			a = a -26;
		}
		a = Math.floor(a/26);
	}
	return r;
}
function toNum(cha) {
	var r = 0;
	for (var i=0; i < cha.length; i++) {
		r += (cha.charCodeAt(i)-64) * Math.pow(26, cha.length - i -1);
	}
	return r;
}
main();

var readline = readline || function() {};
var print = print || console.log || function() { };
function main() {
  var count = readline() || 1;

  while(count--) {
    var line = readline() || 'R8C9'; //R23C55, R875C898,RZ228,R228C494
    var result = '', col, row;
    var p1 = /^R(\d+)+C(\d+)$/;
    var p2 = /^([A-Z]+)(\d+)$/;
    var r1 = line.match(p1);
    var r2 = line.match(p2);
    if (r1 != null) {
      col = r1[2];
      row = r1[1];
      result += Convert2Letter(parseInt(col));
      result += row;
    } else {
      col = r2[1];
      row = r2[2];

      result += 'R' + row;
      result += 'C' + Convert2Number(col);
    }
    print(result);
  }
}
// R228C494
function Convert2Letter(num) {
  var t, result = '', numCopy, arr = [];
  for( numCopy = num; numCopy != 0;) {
    t = numCopy % 26;
    numCopy = Math.floor(numCopy / 26);
    if (t==0) {
      arr.push(String.fromCharCode(64 + 26));
      numCopy--;
    } else {
      arr.push(String.fromCharCode(64 + t));
    }
  }
  arr.reverse();
  return arr.join('');
}
function _Conver2Letter() {
  var result = '';

  return result;
}

function Convert2Number(str) {
  str = str.toUpperCase();
  var result = 0;
  for (var i = 0, j = str.length; i < j; i++) {
    if ( i === j - 1) {
      result = (result + (str[i].charCodeAt() - 64));
    } else {
      result = (result + (str[i].charCodeAt() - 64)) * 26;
    }
  }
  return result;
}
main();

function main() {

	var n = parseInt(readline());
	var coordinates;
    for (var i=0; i < n; i++) {
    	coordinates = readline();

    	var dust = /^R(\d+)C(\d+)$/.exec(coordinates);
    	if (dust) {
    		print(toChar(dust[2]) + dust[1]);
    	} else {
    		dust = /^([A-Z]+)(\d+)$/.exec(coordinates);
    		print("R" + dust[2] + "C" + toNum(dust[1]));
    	}

    }

}
function toChar(num) {
	var a = num;
	var b;
	var r = "";
	while (a!=0) {
		b = a%26;
		if (b != 0) {
			r = String.fromCharCode(b + 64) + r;
		} else {
			r = "Z" + r;
			a--;
		}
		a = Math.floor(a/26);
	}
	return r;
}
function toNum(cha) {
	var r = 0;
	for (var i=0; i < cha.length; i++) {
		r += (cha.charCodeAt(i)-64) * Math.pow(26, cha.length - i -1);
	}
	return r;
}
main();

function getNumToCol(num){
    var dividend = num;
    var columnName = "";
    var modulo;

    while (dividend > 0)
    {
        modulo = (dividend - 1) % 26;
        columnName = String.fromCharCode(65 + modulo).toString() + columnName;
        dividend = parseInt((dividend - modulo) / 26);
    }
    return  columnName;
}

function getColToNum(col) {
    var len = col.length;
    var number = 0;

    for (var i = 0, l = len; i < l; i++) {
        var mod = col[l - (i+1)].charCodeAt() - 64;
        var number = number + (Math.pow(26, i) * mod);
    }

    return String(number);
}

for (var i = 0, l = readline().split(" "); i < l; i++) {
    var n = String(readline().split(" "));
    var int = n.replace(/[^0-9]/g, " ").trim().split(" ");

    // RXCY
    if (n[0] == "R" && int.length == 2) {
        print(getNumToCol(int[1]) + String(int[0]));
    }
    // Nomal
    else if (/[A-Z]/.test(n[0]) && int.length == 1) {
        print("R" + int[0] + "C" + getColToNum(n.replace(/[0-9]/g, " ").split(" ")[0]));
    }
}

var LETTERS = [
  'Z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
  'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y'
];
function main() {
  var numTests = +readline();

  for (var i = 0; i < numTests; i++) {
    print(calc(readline()));
  }
  return 0;
}
main();

function calc(str) {
  return isRC(str) && calcRC(str) || calcNRC(str);
}

function calcRC(str) {
  var res = [];
  var num = parseInt(str.slice(str.indexOf('C') + 1));
  var rest = 0;
  while (num) {
    rest = num % 26;
    res.push(LETTERS[rest]);
    if (rest === 0 && num === 26) break;
if (rest === 0) {num = Math.floor(num / 26) - 1; continue;}
    num = Math.floor(num / 26);
  }

  return res.reverse().join('') + str.slice(1, str.indexOf('C'));
}

function calcNRC(str) {
  var letters = str.slice(0, str.search(/\d/));
  var sum = 0;
  for (var i = letters.length - 1, p = 0; i >= 0; i--, p++) {
    var index = LETTERS.indexOf(letters[i]);
    sum += (index && index || 26) * Math.pow(26, p);
  }
  return 'R' + str.slice(letters.length) + 'C' + sum;
}

function isRC(str) {
  return /^R\d+C\d+$/.test(str);
}

var n = readline();
var numerationSystem = '';

var num = 0;

for (var i = 0; i < n; i++) {
    numerationSystem = readline();

    var idxOfC = numerationSystem.indexOf('C');

    if (numerationSystem.charCodeAt(0) === 82
    && idxOfC !== -1
    && numerationSystem.charCodeAt(idxOfC-1) < 65) {

        var num = numerationSystem.substring(idxOfC+1);
        var alphabet = '';
        alphabet = getAlphabet(num);
        print(alphabet + numerationSystem.substring(1, idxOfC));

    } else {

        var alphabet = numerationSystem.replace(/[0-9]/g, "");
        var num = 0;
        num = getNum(alphabet);
        print('R' + numerationSystem.replace(/\D/g,'') + 'C' + num);
    }

}

function getAlphabet(n) {

	var index = n % 26;
	index = index === 0 ? 26 : index;

    alphabet = String.fromCharCode(64+index) + alphabet;

	n = (n - index) / 26;

	if(n > 0) {
		getAlphabet(n, alphabet);
    }

    return alphabet;

}

function getNum(a) {
    var power = a.length-1;
    var num = 0;
    for (var i = power; i >= 0; i--) {
        num += Math.pow(26, i) * (a.charCodeAt(power - i) - 64);
    }
    return num;

}

var lines = Number(readline());

var letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';

var cases = [];

for(var i = 0; i < lines; i++){
  var data = readline();
  cases.push(toggle(data));
}

print(cases.join('\n'));

function toggle(cell){
    var values = [];
    var chars = false;

    for(var i = 0; i < cell.length; i++){
        if(letters.indexOf(cell[i]) > -1 && chars === true){
            values[values.length - 1] += cell[i];
        }
        if(letters.indexOf(cell[i]) > -1 && chars === false){
            values.push(cell[i]);
            chars = true;
        }
        if(letters.indexOf(cell[i]) === -1 && chars === false){
            values[values.length - 1] += cell[i];
        }
        if(letters.indexOf(cell[i]) === -1 && chars === true){
            values.push(cell[i]);
            chars = false;
        }
    }

    if(values.length === 2){
      // AZnum
      var c = 0;
      var c_str = values[0];
      var r = values[1];
      for(var j = 0; j < c_str.length; j++){
        c =  c * 26 + (letters.indexOf(c_str[j]) + 1);
      }
      return 'R' + r + 'C' + c;
    } else {
      // RXCY
      var r1 = values[1];
      var c1 = Number(values[3]);
      var c1_str = "";

      while(c1 > 0){
        c1_str = letters[(c1 - 1) % 26] + c1_str;
        c1 =  Math.trunc((c1 - 1) / 26);
      }

      return c1_str + r1;
    }

}

function sToInt(s)
{
	var intValue = 0;
	for (var i = 0; i < s.length; i++)
	{
		intValue = intValue * 26 + (s.charCodeAt(i) -"A".charCodeAt(0) + 1);
	}
	return intValue;
}

function intTos(x)
{
	var s = "";
	while (x > 0)
	{
//		print(String.fromCharCode((x - 1) % 26 + "A".charCodeAt(0)));
		s = String.fromCharCode((x - 1) % 26 + "A".charCodeAt(0)) + s;
		if (x % 26 == 0) {
			x = Math.floor(x / 26) - 1;
		} else {
			x = Math.floor(x / 26);
		}
	}
	return s;
}

function main()
{
	var n = readline();

	while (n--) {
		var inputString = readline();
		array = /^R(\d+)C(\d+)/.exec(inputString);
		if (array)
		{
			print(intTos(array[2]) + array[1]);
		}
		else
		{
			array = /^([A-Z]+)(\d+)/.exec(inputString);
			print('R' + array[2] + 'C' + sToInt(array[1]));
		}
	}
}

main();

const CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

function numToCol(num) {
    var n = num;
    var result = "";
    do {
        result = CHARS[ (n-1) % 26 ] + result;
        n = Math.floor( (n-1) / 26 );
    } while(n > 0);
    return result;
}

function colToNum(col) {
    var num = 0;
    for(var i=col.length - 1;i > -1;i--) {
        var chr = col[i];
        var n = Math.pow(26, col.length - i - 1) * (CHARS.indexOf(chr) + 1);
        num += n;
    }
    return num;
}

function trans(coord) {
    if(/^[A-Z]+\d+$/.test(coord)) {
        var col = coord.match(/[A-Z]+/)[0];
        var row = coord.match(/\d+/)[0];
        return  'R' + row + 'C' + colToNum(col);
    } else {
        var row = coord.match(/\d+/)[0];
        var col = coord.match(/\d+$/)[0];
        return  numToCol(col) + row;
    }
}

const n = readline();

while(line = readline()) {
    print( trans(line));
}

function a2c(a){
    var i, c = 0;
    for (i=0; i<a.length; i++){
        c += Math.pow(26, a.length-i-1) * (a.charCodeAt(i) - 65) + Math.pow(26, i);
    }
    return c;
}

function c2a(c){
    var i=0, j=0, a = '', q, r;
    while (true){
    	if (c >= Math.pow(26, i)) {
    		c -= Math.pow(26, i);
    		i++;
    	} else {
    		for (j=0; j<i; j++){
		        q = Math.floor(c / 26);
		        r = c % 26;
	            a = String.fromCharCode(r + 65) + a;
	            c = q;
    		}
            break;
    	}
    }
    return a;
}

function convert(s){
    var i, temp;

    if (/^[A-Z]{1,5}[1-9][0-9]*$/.test(s)) {
        for (i=0; i<s.length; i++){
            if (s.substr(i,1) < 'A'){
                break;
            }
        }
        return "R" + s.substr(i) + "C" + a2c(s.substr(0,i));
    }

    if (/^R[1-9][0-9]*C[1-9][0-9]*$/.test(s)) {
        temp = s.split("C");
        return c2a(temp[1]) + temp[0].substr(1);
    }

    return "Invalid format";
}

var n = readline();
for (var i=0; i<n; i++){
    print(convert(readline()));
}

var alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';

run();

function run() {
  var lines = readline();

  for (var i = 0; i < lines; i++) {
    var line = readline();
    if (line.match(/^R\d+C\d+/)) print(rxcyToExcel(line));
    else print(excelToRxcy(line));
  }
}

function excelToRxcy(excel) {
  var col = excel.match(/[A-Z]*/)[0];
  var row = excel.replace(col, '');
  return 'R' + row + 'C' + alphToNum(col);
}

function rxcyToExcel(rxcy) {
  var row = rxcy.match(/^R[0-9]*/)[0].substring(1);
  var col = rxcy.match(/C[0-9]*/)[0].substring(1);
  return numToAlph(col) + row;
}

function numToAlph(num) {
  var l = alphabet.length,
      digits = 1,
      bound = l;

  // figure out how many digits should be in the result
  while (bound < num) {
    digits++;
    bound += Math.pow(l, digits);
  }

  // adjust num so that our result is the (num)-th string of length (digits)
  for (var i = 1; i < digits; i++) {
    num -= Math.pow(l, i);
  }

  var result = '',
      letterIndex;

  // the i-th digit in the result will be how many times we can divide out 26^i
  // from num, assuming we subtract out the previous multiples of 26^(i+1) in
  // the last step.
  for (var i = digits - 1; i >= 0; i--) {
    letterIndex = Math.floor((num - 1)/Math.pow(l, i))
    num -= Math.pow(l, i) * letterIndex;
    result += alphabet[letterIndex];
  }

  return result;
}

function alphToNum(alph) {
  var digits = alph.length,
      l = alphabet.length,
      num = 0;

  // add to num all the strings of length less than the input string
  for (var i = 0; i < digits; i++) {
    num += Math.pow(l, i);
  }

  // then add to num multiples of powers of 26 for each letter in (alph)
  var letterIndex;
  for (var i = 0; i < digits; i++) {
    letterIndex = alphabet.indexOf(alph[i]);
    num += letterIndex * Math.pow(l, digits - 1 - i);
  }

  return num;
}

//V8 3.31.1

var table = ['Z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
var n = readline();
//var n = 1;

while(n--) {
    var s = readline();
    //var s = "R228C494";
    var e = /R(\d+)C(\d+)/.exec(s);

    if(e) {
        print(getString(e[2]) + e[1]);
    }
    else {
        e = /([A-Z]+)(\d+)/.exec(s);
        print('R' + e[2] + 'C' + getNum(e[1]));
    }
}

function getNum(e) {
    var len = e.length;
    //print(len);
    var total = 0;
    var temp = len;
    for(var i = 0;i < len; i++) {
        for(var j = 1;j <= table.length; j++) {
            if(e[i] == table[j]) {
                //print(j)
                //print(table[j])
                total += j * Math.pow(26, temp - 1);
                //print(total);
                temp--;
            }
        }
    }
    return total;
}

function getString(e) {
    //print(e);
    var answer = '';
    while(e / 26 > 0) {
        answer += table[e % 26];
        //print(e % 26);
        //print(answer);
        if(e % 26 != 0) {
            e = parseInt(e / 26);
        }
        else {
            e = parseInt(e / 26) - 1;
        }
        //print(e);
        //print(table[e % 26]);
    }
    if(e != 0) {
        answer += table[e];
    }
    //print(answer);
    return answer.split("").reverse().join("");
}

var n=parseInt(readline());
var regRC=/R(\d+)C(\d+)/;
var regSP=/([A-Z]+)([0-9]+)/;
for(var i=0;i<n;i++){
	var input=readline();
	var found=input.match(regRC);
	if( found!=null )
	{
		var r=found[1];
		var c=found[2];
		print(number2alpha(parseInt(c))+r);
	}else
	{
		var foundSP=input.match(regSP);
		if(foundSP!=null)
		{
			print('R'+foundSP[2]+'C'+alpha2number(foundSP[1]));
		}
	}
}

function number2alpha(num){
	var result='';
	do {
		var b=num%26;
		if (b==0) {
			result='Z'+result;
			num=num/26-1;
		}else{
			result=String.fromCharCode('A'.charCodeAt(0)+b-1)+result;
			num=Math.floor(num/26);
		}
	} while (num!=0);
	return result;
}

function alpha2number(alpha){
	var result=0;
	for(var i=0;i<alpha.length;i++){
		result+=(alpha.charCodeAt(i)-65+1)*Math.pow(26, alpha.length-1-i);
	}
	return result;
};

var n = readline();
var str;
var sub1,sub2;
var alf = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

var res;

for (var i = 0; i < n; i++){
    str = readline();
    var re1 = /[R]\d+[C]\d+/g;
    var re2 = /\d+/g;
    var re4 = /\d+/;
    var re3 = /[A-Z]+/g;
    res = re1.exec(str);

    if (res != null){
        sub1 = re2.exec(str);
        sub2 = re2.exec(str);
        if (sub2 > 26) sub2--;
        res = "";
        while(sub2/26>=1){
            res = alf[sub2%26]+res;
            sub2 = Math.floor(sub2/26);
            if (sub2 == 26) break;
             if (sub2 > 26) sub2--;
        }
        res = alf[--sub2]+res;
        print(res+sub1);
    }
    else {
        sub = re3.exec(str);
        res = 0;
        sub = sub + "";
        var l = sub.length;
        for (var j = 0; j < l; j++){
            res += (alf.indexOf(sub[j])+1) * Math.pow(26,l-j-1)
        }
        sub = re4.exec(str);
        print("R" + sub + "C" + res);
    }
}

const readline = require('readline');
const rl = readline.createInterface({
	input: process.stdin,
	output: process.stdout,
	terminal: false
});

const abcChars = '_ABCDEFGHIJKLMNOPQRSTUVWXYZ';
const dec2abc = dec => {
	let d = dec;
	let res = '';

	while (d > 0) {
		const mod = d % 26;
		res = abcChars[mod === 0 ? 26 : mod] + res;
		d = Math.floor(d / 26) - (mod === 0 ? 1 : 0);
	}

	return res;
};
const abc2dec = abc => {
	let res = 0;

	for (let i = 0; i < abc.length; i++) {
		res += abcChars.indexOf(abc[i]);
		if (i !== abc.length - 1) {
			res *= 26;
		}
	}

	return res;
};

let n, counter = 0;
const res = [];

rl.on('line', function (line) {
	if (!n) {
		n = parseInt(line);
	} else {
		const rc = line.match(/R(\d+)C(\d+)/);
		if (rc) {
			res.push(dec2abc(parseInt(rc[2])) + rc[1]);
		} else {
			const regular = line.match(/([^\d]+)(\d+)/);
			res.push('R' + regular[2] + 'C' + abc2dec(regular[1]));
		}

		counter++;
		if (counter === n) {
			for (let i = 0; i < res.length; i++) {
				console.log(res[i]);
			}
			rl.close();
		}
	}
});

function baseToDec(baseRep, baseMap) {
    const baseSize = Object.keys(baseMap).length - 1;
    let res = 0;
    for (let i = 0; i < baseRep.length - 1; i++) {
        const w = baseRep[i];
        res = (res + baseMap[w]) * baseSize;
    }
    res = res + baseMap[baseRep[baseRep.length - 1]];
    return res;
}

function decToBase(num, baseMap) {
    const baseSize = Object.keys(baseMap).length - 1;

    const inverseBaseMap = {};
    for (let w of Object.keys(baseMap)) {
        inverseBaseMap[baseMap[w]] = w;
    }

    if (num === 0) {
        return inverseBaseMap[0];
    }

    let rep = [];

    while (num !== 0) {
        let rem = num % baseSize;
        rem = rem === 0 ? baseSize : rem;
        rep.push(inverseBaseMap[rem]);
        num = (num - rem) / baseSize;
    }

    return rep.reverse().join("");
}

function rowColToStand(rowCol) {
    const RC = rowCol.match(/R(.*)C(.*)/);
    return { row: Number(RC[1]), col: Number(RC[2]) };
}

function standToRowCol(stand) {
    return `R${stand.row}C${stand.col}`;
}

const alphaBase = "_ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("").reduce((acc, curr, i) => {
    acc[curr] = i;
    return acc;
}, {});

function alphaToStand(alpha) {
    const RC = alpha.match(/([A-Z]*)([0-9]*)/);
    const alphaCol = RC[1];
    const row = Number(RC[2]);
    const col = baseToDec(alphaCol, alphaBase);
    return { row, col };
}

function standToAlpha(stand) {
    return `${decToBase(stand.col, alphaBase)}${stand.row}`;
}

process.stdin.read();

let line = "";
process.stdin.on("data", w => {
    line += w;
});

process.stdin.on("end", () => {
    const lines = line
        .split(/\r?\n/g)
        .filter(l => l.length !== 0)
        .slice(1);

    lines.forEach(line => {
        if (line.match(/^[A-Z]+[0-9]+$/)) {
            console.log(standToRowCol(alphaToStand(line)));
        }

        if (line.match(/^R[0-9]+C[0-9]+$/)) {
            console.log(standToAlpha(rowColToStand(line)));
        }
    });
});

// http://codeforces.com/problemset/problem/1/B
// B. Электронные таблицы
'use strict';

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

const input = [];
rl.on('line', (line) => { input.push(line); });

rl.on('close', function () {
  const BASE = 26;
  const UTF8_SHIFT = 'A'.charCodeAt(0) - 1;

  for (let i = 1; i < input.length; i++) {

    let blocks = [];
    let block = '';
    let lastChar = null;

    for (let j = 0; j < input[i].length; j++) {
      if (isNumeric(lastChar) !== isNumeric(input[i][j])) {
        blocks.push(block);
        block = '';
      }
      lastChar = input[i][j];
      block += input[i][j];
    }
    blocks.push(block);

    if (blocks.length === 2) {

      let column = blocks[0].split('').reduce(function (result, elem, index, arr) {
        result += (elem.charCodeAt(0) - UTF8_SHIFT) * Math.pow(BASE, arr.length - index - 1);
        return result;
      }, 0)
      console.log('R' + blocks[1] + 'C' + column);

    } else {

      let column = +blocks[3];
      let columnChars = [];

      while (column > 0) {
        column--;
        columnChars.push(String.fromCharCode(UTF8_SHIFT + column % BASE + 1));
        column = Math.floor(column / BASE);
      }
      console.log(columnChars.reverse().join('') + blocks[1]);

    }
  }
});

function isNumeric(n) {
  return !isNaN(parseFloat(n)) && isFinite(n);
}

var num2string = function (num) {
    var sLen = 1;
    var t = 26;
    while (num > t) {
        num -= t;
        sLen ++;
        t *= 26;
    }
    num --;
    var res = "";
    for (var i = 0; i < sLen; i ++) {
        res = String.fromCharCode(65 + num % 26) + res;
        num = parseInt(num / 26);
    }
    return res;
};

var string2num = function (s) {
    var sLen = s.length;
    var res = 0;
    var t = 26;
    for (var i = 0; i < sLen-1; i ++) {
        res += t;
        t *= 26;
    }
    res += 1;
    t = 1;
    for (var i = sLen-1; i >= 0; i --) {
        res += (s[i].charCodeAt() - 65) * t;
        t *= 26;
    }
    return res;
};

var check1 = function (s) {
    if (s[0] == 'R' && s[1].charCodeAt() <= 57 && s.indexOf("C") != -1) {
        var idx = s.indexOf("C");
        var num1 = parseInt(s.substring(1, idx));
        var num2 = parseInt(s.substring(idx+1));
        print(num2string(num2) + num1);
        return true;
    }
    else {
        return false;
    }
};

var check2 = function (s) {
    var idx = 0;
    for (idx = 0; idx < s.length; idx ++) {
        if (s[idx].charCodeAt() <= 57)
            break;
    }
    var subs = s.substring(0, idx);
    print("R" + s.substring(idx) + "C" + string2num(subs));
};

n = parseInt(readline());
for (var i = 0; i < n; i ++) {
    var s = readline();
    if (!check1(s))
        check2(s);
}

var n = parseInt(readline());
for (var i = 0; i < n; i++) {
	var s = readline();
	if (/R\d+C\d+/.test(s)) {
		var matches = /R(\d+)C(\d+)/g.exec(s);
		print(function(num) {
			var mul = 26, length = 1, res = 26;
			while (num > res) {
				num -= res;
				length++;
				res *= mul;
			}
			var ans = "";
			for (var j = 0; j < length; j++) {
				res /= mul;
				var cur = "A".charCodeAt(0);
				while (num > res) {
					num -= res;
					++cur;
				}
				ans += String.fromCharCode(cur);
			}
			return ans;
		} (parseInt(matches[2])) + matches[1]);
	} else {
		var matches = /([A-Z]+)(\d+)/g.exec(s);
		print("R" + matches[2] + "C" + function(str) {
			var mul = 26, res = 26, ans = 0;
			for (var j = 1; j < str.length; j++) {
				ans += res;
				res *= mul;
			}
			for (var j = 0; j < str.length; j++) {
				var num = str.charCodeAt(j);
				var cur = "A".charCodeAt(0);
				res /= mul;
				ans += res * (num - cur);
			}
			return ans + 1;
		} (matches[1]));
	}
}

//var fs = require('fs');

//var readline = (function () {
	//var file = fs.readFileSync('input.txt', 'utf-8').split('\n');
	//return function () {
		//return file.shift()
	//}
//})();
//var print = console.log;

var numberOfLines = Number(readline());

for (var i = 0; i < numberOfLines; i++) {
    var line = readline();
    if (/R\d+C\d+/.test(line)) {
        line = line.slice(1).split('C');
        var rowsTmp = Number(line[1]);
        var cols = Number(line[0]);
        var rows = '';

        while (rowsTmp > 0) {
            var currentCharCode = 64 + (rowsTmp % 26 === 0 ? 26 : rowsTmp % 26);

            rows = String.fromCharCode(currentCharCode) + rows;
            rowsTmp = Math.floor(rowsTmp / 26) - (rowsTmp % 26 === 0 ? 1 : 0);
        }

        print(rows + cols);

    } else {
        var tmp = /([A-Z]+)(\d+)/.exec(line);
        var cols = tmp[2];
        var rowsTmp = tmp[1];
        var rows = 0;

        for (var j = 0; j < rowsTmp.length; j++) {
            rows = rows * 26 + (rowsTmp[j].charCodeAt(0) - 64)
        }

        print('R' + cols + 'C' + rows);
    }
}

var a,b;
readline();

while(a=readline())print((b=a.match(/R(\d+)C(\d+)/))?M(b[2])+b[1]:(b=a.match(/^([A-Z]+)(\d+)$/),'R'+b[2]+'C'+N(b[1])));

function N(l){
  var n=l.length-1,i=v=0,c;
	for(;c=l.charCodeAt(i)-64;i++)v=v+Math.pow(26,n-i)*c;
	return v;
}

function M(l){
  var a='';
  for(;l;l=parseInt(l/26)){
	  a=String.fromCharCode(--l%26+65)+a;
	}
	return a;
}

var a,b;
readline();

while(a=readline())print((b=a.match(/R(\d+)C(\d+)/))?M(b[2])+b[1]:(b=a.match(/^([A-Z]+)(\d+)$/),'R'+b[2]+'C'+N(b[1])));

function N(l){
  var n=l.length-1,i=v=0,c;
	for(;c=l.charCodeAt(i)-64;i++)v=v+Math.pow(26,n-i)*c;
	return v;
}

function M(l){
  var a='';
  for(;l>26;l=parseInt(l/26)){
	  l--;
	  a=String.fromCharCode(l%26+65)+a;
	}
	return String.fromCharCode(+l+64)+a;
}

var a, b;
readline();

while (a = readline()) {
  print((b = a.match(/R(\d+)C(\d+)/)) ?
    M(b[2]) + b[1] :
    (b = a.match(/^([A-Z]+)(\d+)$/), 'R' + b[2] + 'C' + M(b[1])));
}

function M(l) {
  var a = '', n = l.length - 1, i = v = 0, c;
  if (l - 1) {
    for (; l; l = parseInt(l / 26)) a = String.fromCharCode(--l % 26 + 65) + a;
    return a;
  } else {
    for (; c = l.charCodeAt(i) - 64; i++) v = v + Math.pow(26, n - i) * c;
    return v;
  }
}

var a,b;
readline();

while(a=readline())print((b=a.match(/R(\d+)C(\d+)/))?M(b[2])+b[1]:(b=a.match(/^([A-Z]+)(\d+)$/),'R'+b[2]+'C'+N(b[1])));

function N(l){
  var n=l.length-1,i=v=0,c;
	for(;c=l.charCodeAt(i)-64;i++)v=v+Math.pow(26,n-i)*c;
	return v;
}

function M(l){
  var a='';
  for(;l>26;l=parseInt(l/26)){
	  a=String.fromCharCode(--l%26+65)+a;
	}
	return String.fromCharCode(+l+64)+a;
}

(function() {
  var count = parseInt(readline());
  var input = [];

  var offset = 'A'.charCodeAt(0) - 1; // A = 1
  var maxChar = 26;
  // AA = 26 + 1 = 27

  for (var i = 0; i < count; i++) {
    input.push(readline());
  }

  input.map(function(x) {
    var matches = x.match(/^R(\d+)C(\d+)$/);
    if (matches != null) {
      print(convertToA(matches[1], matches[2]));
    } else {
      matches = x.match(/(^[A-Z]+)(\d+)$/);
      if (matches != null) {
        print(convertToRC(matches[2], matches[1]));
      }
    }
  });

  function convertToA(row, col) {
    // row and col are one-based
    return convertNToA(col) + row;
  }

  function convertToRC(row, col) {
    // col is A, B, C
    return 'R' + row + 'C' + convertAToN(col);
  }

  function convertAToN(input) {
    var output = 0;
    for (var i = 0; i < input.length; i++) {
      var n = input.charCodeAt(i) - offset;
      var pow = input.length - 1 - i;
      output += Math.pow(maxChar, pow) * n;
    }
    return output;
  }

  function convertNToA(input) {
    var output = '';
    var pow = 0;
    while (input > 0) {
      var a = input % Math.pow(maxChar, pow + 1);
      if (a == 0) {
        input -= Math.pow(maxChar, pow + 1);
        output = 'Z' + output;
      } else if (a > 0) {
        input -= a;
        output = String.fromCharCode(a / Math.pow(maxChar, pow) + offset) + output;
      }
      pow++;
    }
    return output;
  }
})();

// 1B   Электронные таблицы

var n = parseInt(readline());
//var input_line = readline().split(' ').map(Number);
//var n =  input_line[0];
//var m =  input_line[1];

var arr = [];
var out ='';
var reg = /^[R][\d]+[C][\d]+/;
var x, y;

var abc = '0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0';
arr = abc.split(' ');

var arr_S = [];
for (var i = 0; i < arr.length; i++) {
    arr_S[arr[i]] = i;
};

for (var i = 0; i < n; i++) {

    str = readline();

    if (reg.test(str)) {
        for (var j = 1; /\d/.test(str[j]); j++) {};
        x = str.substring(1, j); // номер строки
        y = str.substring(j+1, str.length );
        var pos = parseInt(y); // числовой номер столбца

        var abc = '';
        var ost;
        while(pos != 0) {
            ost = pos % 26;
            if (ost != 0) {
                abc = arr[ost] + abc;
            } else {
                abc = 'Z' + abc;
                pos --;
            };
            pos = Math.floor(pos/26);
        }

        out += abc + x + "\n";

    } else {
        x = str.match(/\d+/); // номер строки
        y = str.match(/[A-Z]+/);   // буквенный номер столбца
        var len = y[0].length;
        var posN = 0; // числовой номер столбца
        for (var j = len; j > 0; j--) {
            posN += arr_S[y[0].substring(len-j, len-j+1)] * Math.pow(26, j-1);
        };

        out += 'R' + x + 'C' + posN.toString() + "\n";

    }
};

print(out);

t = readline();

A = 65;

numToLetters = num => {
    ret = ""
    while(num>0) {
      ret += (String.fromCharCode(A+(num-1)%26));
      num = Math.floor((num-1)/26);
    }
    return ret.split("").reverse().join("");
};

lettersToNum = letters => {
    ret = 0;
    mult = 1;
    for(i=letters.length-1; i>=0; i--) {
        ret += (1 + letters.charCodeAt(i)-A) * mult;
        mult *= 26;
    }
    return ret;
}

while(t--) {
    input = readline();
    numbas = input.split(/([0-9]+)/);
    numbas.pop();

    if (numbas.length == 4) {
        col = parseInt(numbas[3]);
        print(numToLetters(col)+numbas[1]);
    } else {
        print('R'+numbas[1]+'C'+lettersToNum(numbas[0]));
    }
}

var n = readline();
var str;
var sub1,sub2;
var alf = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

var res;

for (var i = 0; i < n; i++){
    str = readline();
    var re1 = /[R]\d+[C]\d+/g;
    var re2 = /\d+/g;
    var re4 = /\d+/;
    var re3 = /[A-Z]+/g;
    res = re1.exec(str);

    if (res != null){
        sub1 = re2.exec(str);
        sub2 = re2.exec(str);
        if (sub2 > 26) sub2--;
        res = "";
        while(sub2/26>=1){
            res = alf[sub2%26]+res;
            sub2 = Math.floor(sub2/26);
             if (sub2 > 26) sub2--;
        }
        res = alf[--sub2]+res;
        print(res+sub1);
    }
    else {
        sub = re3.exec(str);
        res = 0;
        sub = sub + "";
        var l = sub.length;
        for (var j = 0; j < l; j++){
            res += (alf.indexOf(sub[j])+1) * Math.pow(26,l-j-1)
        }
        sub = re4.exec(str);
        print("R" + sub + "C" + res);
    }
}

function main() {
  var tests = readline().split('\n').slice(1);
  var LETTERS = [
    'Z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
    'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y'
  ];

  for (var i = 1; i < tests.length; i++) {
    print(calc(tests[i]) + '\n');
  }
  return 0;
}
main();

function calc(str) {
  return isRC(str) && calcRC(str) || calcNRC(str);
}

function calcRC(str) {
  var res = [];
  var num = parseInt(str.slice(str.indexOf('C') + 1));
  var rest = 0;
  while (num) {
    rest = num % 26;
    res.push(LETTERS[rest]);
    if (rest === 0 && num === 26) break;
    num = Math.floor(num / 26);
  }

  return res.reverse().join('') + str.slice(1, str.indexOf('C'));
}

function calcNRC(str) {
  var letters = str.slice(0, str.search(/\d/));
  var sum = 0;
  for (var i = letters.length - 1, p = 0; i >= 0; i--, p++) {
    var index = LETTERS.indexOf(letters[i]);
    sum += (index && index || 26) * Math.pow(26, p);
  }
  return 'R' + str.slice(letters.length) + 'C' + sum;
}

function isRC(str) {
  return /^R\d*C\d*$/.test(str);
}

var n=parseInt(readline());
var regRC=/R(\d+)C(\d+)/;
var regSP=/([A-Z]+)([0-9]+)/;
for(var i=0;i<n;i++){
	var input=readline();
	var found=input.match(regRC);
	if( found!=null )
	{
		var r=found[1];
		var c=found[2];
		print(number2alpha(parseInt(c))+r);
	}else
	{
		var foundSP=input.match(regSP);
		if(foundSP!=null)
		{
			print('R'+foundSP[2]+'C'+alpha2number(foundSP[1]));
		}

	}

}

function number2alpha(num){
	var result;
	result=String.fromCharCode('A'.charCodeAt(0)+num%26-1);
	var a=Math.floor(num/26);
	if(a>=26)
	{
		result=number2alpha(a)+result;
	}else if(a!=0)
	{
		result=String.fromCharCode('A'.charCodeAt(0)+a-1)+result;
	}
	return result;
};

function alpha2number(alpha){
	var result=0;
	for(var i=0;i<alpha.length;i++){
		result+=(alpha.charCodeAt(i)-65+1)*Math.pow(26, alpha.length-1-i);
	}
	return result;
};

var tests = readline().split('\n').slice(1);
var LETTERS = [
  'Z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
  'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y'
];

for (var i = 1; i < tests.length; i++) {
  print(calc(tests[i]));
}

function calc(str) {
  return isRC(str) && calcRC(str) || calcNRC(str);
}

function calcRC(str) {
  var res = [];
  var num = parseInt(str.slice(str.indexOf('C') + 1));
  var rest = 0;
  while (num) {
    rest = num % 26;
    res.push(LETTERS[rest]);
    if (rest === 0 && num === 26) break;
    num = Math.floor(num / 26);
  }

  return res.reverse().join('') + str.slice(1, str.indexOf('C'));
}

function calcNRC(str) {
  var letters = str.slice(0, str.search(/\d/));
  var sum = 0;
  for (var i = letters.length - 1, p = 0; i >= 0; i--, p++) {
    var index = LETTERS.indexOf(letters[i]);
    sum += (index && index || 26) * Math.pow(26, p);
  }
  return 'R' + str.slice(letters.length) + 'C' + sum;
}

function isRC(str) {
  return /^R\d*C\d*$/.test(str);
}

const n = readline();

const lines = [];
for(var i=0;i<n;i++) {
    lines.push(readline());
}

const CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

function numToCol(num) {
    var n = num;
    var result = "";
    do {
        result = CHARS[ (n-1) % 26 ] + result;
        n = Math.floor( (n-1) / 26 );
    } while(n > 0);
    return result;
}

function colToNum(col) {
    var num = 0;
    for(var i=col.length - 1;i > -1;i--) {
        const chr = col[i];
        const n = Math.pow(26, col.length - i - 1) * (CHARS.indexOf(chr) + 1);
        console.log(n);
        num += n;
    }
    return num;
}

function trans(coord) {
    if(/R\d+C\d+/.test(coord)) {
        const row = coord.match(/\d+/)[0];
        const col = coord.match(/\d+$/)[0];
        return  numToCol(col) + row;
    } else {
        const col = coord.match(/[A-Z]+/)[0];
        const row = coord.match(/\d+/)[0];
        return  'R' + row + 'C' + colToNum(col);
    }
}

for(var i in lines) {
    const line = lines[i];
    print(line);
}

var table = [0, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
//var n = readline();
var n = 1;

while(n--) {
    //var s = readline();
    var s = "R23C55";
    var e = /R(\d+)C(\d+)/.exec(s);

    if(e) {
        print(getString(e[2]) + e[1]);
    }
    else {
        e = /([A-Z]+)(\d+)/.exec(s);
        print('R' + e[2] + 'C' + getNum(e[1]));
    }
}

function getNum(e) {
    var len = e.length;
    //print(len);
    var total = 0;
    var temp = len;
    for(var i = 0;i < len; i++) {
        for(var j = 1;j <= table.length; j++) {
            if(e[i] == table[j]) {
                //print(j)
                //print(table[j])
                total += j * Math.pow(26, temp - 1);
                //print(total);
                temp--;
            }
        }
    }
    return total;
}

function getString(e) {
    //print(e);
    var answer = '';
    while(e / 26 > 0) {
        answer += table[e % 26];
        //print(answer);
        e = parseInt(e / 26);
        //print(e);
        //print(table[e % 26]);
    }
    if(e != 0) {
        answer += table[e];
    }
    //print(answer);
    return answer.split("").reverse().join("");
}

function baseToDec(baseRep, baseMap) {
    const baseSize = Object.keys(baseMap).length - 1;
    let res = 0;
    for (let i = 0; i < baseRep.length - 1; i++) {
        const w = baseRep[i];
        res = (res + baseMap[w]) * baseSize;
    }
    res = res + baseMap[baseRep[baseRep.length - 1]];
    return res;
}

function decToBase(num, baseMap) {
    const baseSize = Object.keys(baseMap).length - 1;

    const inverseBaseMap = {};
    for (let w of Object.keys(baseMap)) {
        inverseBaseMap[baseMap[w]] = w;
    }

    if (num === 0) {
        return inverseBaseMap[0];
    }

    let rep = [];

    while (num !== 0) {
        let rem = num % baseSize;
        rem = rem === 0 ? baseSize : rem;
        rep.push(inverseBaseMap[rem]);
        num = (num - rem) / baseSize;
    }

    return rep.reverse().join("");
}

function rowColToStand(rowCol) {
    const RC = rowCol.match(/R(.*)C(.*)/);
    return { row: Number(RC[1]), col: Number(RC[2]) };
}

function standToRowCol(stand) {
    return `R${stand.row}C${stand.col}`;
}

const alphaBase = "_ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("").reduce((acc, curr, i) => {
    acc[curr] = i;
    return acc;
}, {});

function alphaToStand(alpha) {
    const RC = alpha.match(/([A-Z]*)([0-9]*)/);
    const alphaCol = RC[1];
    const row = Number(RC[2]);
    const col = baseToDec(alphaCol, alphaBase);
    return { row, col };
}

function standToAlpha(stand) {
    return `${decToBase(stand.col, alphaBase)}${stand.row}`;
}

process.stdin.read();

process.stdin.on("data", w => {
    const lines = w
        .toString()
        .trim()
        .split("\n");
    console.log(lines);
    lines.forEach(line => {
        if (line.match(/^[A-Z]+[0-9]+$/)) {
            console.log(standToRowCol(alphaToStand(line)));
        }

        if (line.match(/^R[0-9]+C[0-9]+$/)) {
            console.log(standToAlpha(rowColToStand(line)));
        }
    });
});

var lines = Number(readline());

var letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';

var cases = [];

for(var i = 0; i < lines; i++){
  var data = readline();
  cases.push(toggle(data));
}

print(cases.join('\n'));

function toggle(cell){
    var values = [];
    var chars = false;

    for(var i = 0; i < cell.length; i++){
        if(letters.indexOf(cell[i]) > -1 && chars === true){
            values[values.length - 1] += cell[i];
        }
        if(letters.indexOf(cell[i]) > -1 && chars === false){
            values.push(cell[i]);
            chars = true;
        }
        if(letters.indexOf(cell[i]) === -1 && chars === false){
            values[values.length - 1] += cell[i];
        }
        if(letters.indexOf(cell[i]) === -1 && chars === true){
            values.push(cell[i]);
            chars = false;
        }
    }

    if(values.length === 2){
      // AZnum
      var r = 0;
      var r_str = values[0];
      var c = values[1];
      for(var j = 0; j < r_str.length; j++){
        r =  r * 26 + (letters.indexOf(r_str[j]) + 1);
      }
      return 'R' + r + 'C' + c;
    } else {
      // RXCY
      var r1 = Number(values[1]);
      var r1_str = "";
      var c1 = values[3];

      while(r1 > 0){
        r1_str = letters[(r1 - 1) % 26] + r1_str;
        r1 =  Math.trunc((r1 - 1) / 26);
      }

      return r1_str + c1;
    }

}

// 1B   Электронные таблицы
/*
function main_1(){
    var n = parseInt(readline());
    var ans = 0;
    while (n--) {
        var nums = readline().split(' ').map(Number);
        ans += (nums[2] - nums[0] + 1) * (nums[3] - nums[1] + 1);
    }
    print(ans);
}

function main(){
    var line  = readline();
    //var line = prompt();
    var n = line.length;
    //alert(line);
    var m = 0;
    for(i=0;i<n;i+=2){
        for(j=i+1;j<n;j+=2){
            var ex = [line.slice(0, i), '(', line.slice(i,j) , ')' , line.slice(j)].join('');
            m = Math.max(m,eval(ex));
        }
    }
    print(m);
}
*/

var n = parseInt(readline());
//var input_line = readline().split(' ').map(Number);
//var n =  input_line[0];
//var m =  input_line[1];

var arr = [];
var out ='';
var reg = /^[R][\d]+[C][\d]+/;
var x, y;

var abc = '0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z';
arr = abc.split(' ');

var arr_S = [];
for (var i = 0; i < arr.length; i++) {
    arr_S[arr[i]] = i;
};
// RAA23R23C78
// RAA23
// R23C78

for (var i = 0; i < n; i++) {

    str = readline();

    if (reg.test(str)) {
        for (var j = 1; /\d/.test(str[j]); j++) {};
        x = str.substring(1, j); // номер строки
        y = str.substring(j+1, str.length );
        var pos = parseInt(y); // числовой номер столбца
        var valpor = 26; // значение порядка числа в 26-ричной системе
        var por = 1; // порядок числа в 26-ричной системе

        while (valpor <= pos) {
            por ++;
            valpor = por * 26;
        }

        for (var j = por; j >=1; j--) {
            for (var k = 2; k <= 26; k++) {
                if (j * 26 * k > pos) {
                    out += arr[k-1];
                    pos -= j * (k - 1);
                    break;
                };
            };
        };

        out += x + "\n";

    } else {
        x = str.match(/\d+/); // номер строки
        y = str.match(/[A-Z]+/);   // буквенный номер столбца
        var len = y.length;
        var posN = 0; // числовой номер столбца
        for (var j = len; j >= 0; j--) {
            posN += arr_S[str[j]] * j * 26;
        };

        out += 'R' + x + 'C' + posN.toString() + "\n";

    }
};

print(out);

var c = readline(), s, m;

while(c--){
	s = readline();
	m = /^R(\d+)C(\d+)/.exec(s);

	if( m ){
		print( toChar(m[2]) + m[1] );
	}else{
		m = /^(\w+)(\d+)/.exec(s);
		print('R' + m[2] + 'C' + toNum(m[1]).toString(10) );
	}
}

function toChar(num){
	var ret = '';
	var m = num%26;
	while( num > 26 ){
		ret = String.fromCharCode( m+64 ) +ret;
		num = (num - m)/26
		m = num%26
	}
	return String.fromCharCode( m+64 ) +ret;
}

function toNum(char){
	var l = char.length;
	var ret = 0;
	var t = 1;
	while(l--){
		ret += ( char.charCodeAt(l)-64 ) * t;
		t *= 26
	}
	return ret;
}

// 1B   Электронные таблицы

var n = parseInt(readline());
//var input_line = readline().split(' ').map(Number);
//var n =  input_line[0];
//var m =  input_line[1];

var arr = [];
var out ='';
var reg = /^[R][\d]+[C][\d]+/;
var x, y;

var abc = '0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ';
arr = abc.split(' ');

var arr_S = [];
for (var i = 0; i < arr.length; i++) {
    arr_S[arr[i]] = i;
};

// expected: 'RZ228', found: 'SA228'

for (var i = 0; i < n; i++) {

    str = readline();

    if (reg.test(str)) {
        for (var j = 1; /\d/.test(str[j]); j++) {};
        x = str.substring(1, j); // номер строки
        y = str.substring(j+1, str.length );
        var pos = parseInt(y); // числовой номер столбца
        var valpor = 26; // значение порядка числа в 26-ричной системе
        var por = 1; // порядок числа в 26-ричной системе

        while (valpor < pos) {
            por ++;
            valpor = valpor * 26;
        }

        for (var j = por; j >=1; j--) {
            for (var k = 2; k <= 26; k++) {
                if (Math.pow(26, j-1) * k > pos) {
                    out += arr[k-1];
                    pos -= Math.pow(26, j-1) * (k - 1);
                    break;
                };
                if (Math.pow(26, j-1) * k === pos) {
                    if (j === 1) {
                        out += arr[k];
                    } else {
                        out += arr[k-1];
                    };
                    pos -= Math.pow(26, j-1) * (k-2);
                    break;
                };
            };
        };

        out += x + "\n";

    } else {
        x = str.match(/\d+/); // номер строки
        y = str.match(/[A-Z]+/);   // буквенный номер столбца
        var len = y[0].length;
        var posN = 0; // числовой номер столбца
        for (var j = len; j > 0; j--) {
            posN += arr_S[y[0].substring(len-j, len-j+1)] * Math.pow(26, j-1);
        };

        out += 'R' + x + 'C' + posN.toString() + "\n";

    }
};

print(out);

var n = parseInt(readline());

print(n);

// 1B   Электронные таблицы
/*
function main_1(){
    var n = parseInt(readline());
    var ans = 0;
    while (n--) {
        var nums = readline().split(' ').map(Number);
        ans += (nums[2] - nums[0] + 1) * (nums[3] - nums[1] + 1);
    }
    print(ans);
}

function main(){
    var line  = readline();
    //var line = prompt();
    var n = line.length;
    //alert(line);
    var m = 0;
    for(i=0;i<n;i+=2){
        for(j=i+1;j<n;j+=2){
            var ex = [line.slice(0, i), '(', line.slice(i,j) , ')' , line.slice(j)].join('');
            m = Math.max(m,eval(ex));
        }
    }
    print(m);
}
*/

var n = parseInt(readline());
//var input_line = readline().split(' ').map(Number);
//var n =  input_line[0];
//var m =  input_line[1];

var arr = [];
var out ='';
var reg = /^[R][\d]+[C][\d]+/;
var x, y;

var abc = '0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z';
arr = abc.split(' ');

var arr_S = [];
for (var i = 0; i < arr.length; i++) {
    arr_S[arr[i]] = i;
};
// RAA23R23C78
// AAA23

//R23C78

for (var i = 0; i < n; i++) {

    str = readline();

    if (reg.test(str)) {
        for (var j = 1; /\d/.test(str[j]); j++) {};
        x = str.substring(1, j); // номер строки
        y = str.substring(j+1, str.length );
        var pos = parseInt(y); // числовой номер столбца
        var valpor = 26; // значение порядка числа в 26-ричной системе
        var por = 1; // порядок числа в 26-ричной системе

        while (valpor < pos) {
            por ++;
            valpor = valpor * 26;
        }

        for (var j = por; j >=1; j--) {
            for (var k = 2; k <= 26; k++) {
                if (Math.pow(26, j-1) * k > pos) {
                    out += arr[k-1];
                    pos -= Math.pow(26, j-1) * (k - 1);
                    break;
                };
            };
        };

        out += x + "\n";

    } else {
        x = str.match(/\d+/); // номер строки
        y = str.match(/[A-Z][A-Z]/);   // буквенный номер столбца
        var len = y[0].length;
out += len + ' y=' + y + ' ';
        var posN = 0; // числовой номер столбца
        for (var j = len; j > 0; j--) {
            posN += arr_S[y[0].substring(len-j, len-j+1)] * Math.pow(26, j-1);
        };

        out += 'R' + x + 'C' + posN.toString() + "\n";

    }
};

print(out);

const n = readline();

const lines = [];
for(var i=0;i<n;i++) {
    lines.push(readline());
}

const CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

function numToCol(num) {
    var n = num;
    var result = "";
    do {
        result = CHARS[ (n-1) % 26 ] + result;
        n = Math.floor( (n-1) / 26 );
    } while(n > 0);
    return result;
}

function colToNum(col) {
    var num = 0;
    for(var i=col.length - 1;i > -1;i--) {
        const chr = col[i];
        const n = Math.pow(26, col.length - i - 1) * (CHARS.indexOf(chr) + 1);
        num += n;
    }
    return num;
}

function trans(coord) {
    if(/^[A-Z]+\d+$/.test(coord)) {
        var col = coord.match(/[A-Z]+/)[0];
        var row = coord.match(/\d+/)[0];
        return  'R' + row + 'C' + colToNum(col);
    } else {
        var row = coord.match(/\d+/)[0];
        var col = coord.match(/\d+$/)[0];
        return  numToCol(col) + row;
    }
}

do {
    const line = lines.shift();
    print(line);
} while(lines.length > 0);

// 1B   Электронные таблицы

var n = parseInt(readline());
//var input_line = readline().split(' ').map(Number);
//var n =  input_line[0];
//var m =  input_line[1];

var arr = [];
var out ='';
var reg = /^[R][\d]+[C][\d]+/;
var x, y;

var abc = 'A B C D E F G H I J K L M N O P Q R S T U V W X Y Z';
arr = abc.split(' ');

var arr_S = [];
for (var i = 0; i < arr.length; i++) {
    arr_S[arr[i]] = i;
};

// expected: 'RZ228', found: 'SA228'

for (var i = 0; i < n; i++) {

    str = readline();

    if (reg.test(str)) {
        for (var j = 1; /\d/.test(str[j]); j++) {};
        x = str.substring(1, j); // номер строки
        y = str.substring(j+1, str.length );
        var pos = parseInt(y); // числовой номер столбца
        var valpor = 26; // значение порядка числа в 26-ричной системе
        var por = 1; // порядок числа в 26-ричной системе

        while (valpor < pos) {
            por ++;
            valpor = valpor * 26;
        }

        for (var j = por; j >=1; j--) {
            for (var k = 1; k <= 26; k++) {
                if (Math.pow(26, j-1) * k > pos) {
                    out += arr[k];
                    pos -= Math.pow(26, j-1) * (k);
                    break;
                };
                if (Math.pow(26, j-1) * k === pos) {
                    if (j === 1) {
                        out += arr[k+1];
                    } else {
                        out += arr[k];
                    };
                    pos -= Math.pow(26, j-1) * (k);
                    break;
                };
            };
        };

        out += x + "\n";

    } else {
        x = str.match(/\d+/); // номер строки
        y = str.match(/[A-Z]+/);   // буквенный номер столбца
        var len = y[0].length;
        var posN = 0; // числовой номер столбца
        for (var j = len; j > 0; j--) {
            posN += arr_S[y[0].substring(len-j-1, len-j)] * Math.pow(26, j-1);
        };

        out += 'R' + x + 'C' + posN.toString() + "\n";

    }
};

print(out);

function main() {
  var tests = readline().split('\n').slice(1);
  var LETTERS = [
    'Z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
    'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y'
  ];

  for (var i = 1; i < tests.length; i++) {
    print(calc(tests[i]));
  }
  return 0;
}
main();

function calc(str) {
  return isRC(str) && calcRC(str) || calcNRC(str);
}

function calcRC(str) {
  var res = [];
  var num = parseInt(str.slice(str.indexOf('C') + 1));
  var rest = 0;
  while (num) {
    rest = num % 26;
    res.push(LETTERS[rest]);
    if (rest === 0 && num === 26) break;
    num = Math.floor(num / 26);
  }

  return res.reverse().join('') + str.slice(1, str.indexOf('C'));
}

function calcNRC(str) {
  var letters = str.slice(0, str.search(/\d/));
  var sum = 0;
  for (var i = letters.length - 1, p = 0; i >= 0; i--, p++) {
    var index = LETTERS.indexOf(letters[i]);
    sum += (index && index || 26) * Math.pow(26, p);
  }
  return 'R' + str.slice(letters.length) + 'C' + sum;
}

function isRC(str) {
  return /^R\d*C\d*$/.test(str);
}

var pos = readline();
var array = [];
var ascii = 64;
var num26 = 26;

for (var i = 0; i < pos; i++) {
    array.push(readline());
}

for (var i = 0; i < array.length; i++) {
    var text = array[i];
    var pattern = /R[(0-9)]{1,100}C[(0-9)]{1,100}/;
    if (pattern.test(text)) {
        var row = 0;
        var col = 0;
        var separator = 0;
        for (var j = 0; j < text.length; j++) {
            if (text[j] == 'C') {
                separator = j;
            }
        }

        var row = parseInt(text.substring(0, separator).replace(/[^0-9]/g, ''));
        var col = parseInt(text.substring(separator, text.length).replace(/[^0-9]/g, ''));
        var text = '';
        while(col > 0) {
            if (col < num26) break;

            var remain = col % num26;
            col = col / num26;

            var char = String.fromCharCode(remain + ascii);
            text = char + text;
        }

        var first = String.fromCharCode(col + ascii);
        text = first + text;

        var converted = text + row;
        print(converted);
    } else {
        var separator = 0;
        for (var j = 0; j < text.length; j++) {
            var number = parseInt(text[j]);
            if (number >= 0 && number <= 9) {
                separator = j;
                break;
            }
        }

        var row = parseInt(text.substring(separator, text.length));
        var col = text.substring(0, separator);
        var colNum = 0;
        col = col.split('').reverse();
        for (var j = 0; j < col.length; j++) {
            var char = col[j].toUpperCase().charCodeAt(0) - ascii;
            if (j === 0) {
                colNum += char;
            } else {
                colNum += (Math.pow(num26, j) * char);
            }
        }

        var converted = 'R' + row + 'C' + colNum;
        print(converted);
    }
}

var LETTERS = [
  'Z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
  'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y'
];
function main() {
  var numTests = +readline();

  for (var i = 0; i < numTests; i++) {
    print(calc(readline()));
  }
  return 0;
}
main();

function calc(str) {
  return isRC(str) && calcRC(str) || calcNRC(str);
}

function calcRC(str) {
  var res = [];
  var num = parseInt(str.slice(str.indexOf('C') + 1));
  var rest = 0;
  while (num) {
    rest = num % 26;
    res.push(LETTERS[rest]);
    if (rest === 0 && num === 26) break;
if (rest === 0) {num = Math.floor(num / 26) - 1; continue;}
    num = Math.floor(num / 26);
  }

  return res.reverse().join('') + str.slice(1, str.indexOf('C'));
}

function calcNRC(str) {
  var letters = str.slice(0, str.search(/\d/));
  var sum = 0;
  for (var i = letters.length - 1, p = 0; i >= 0; i--, p++) {
    var index = LETTERS.indexOf(letters[i]);
    sum += (index && index || 26) * Math.pow(26, p);
  }
  return 'R' + str.slice(letters.length) + 'C' + sum;
}

function isRC(str) {
  return /^R\d*C\d*$/.test(str);
}

// 1B   Электронные таблицы

var n = parseInt(readline());
//var input_line = readline().split(' ').map(Number);
//var n =  input_line[0];
//var m =  input_line[1];

var arr = [];
var out ='';
var reg = /^[R][\d]+[C][\d]+/;
var x, y;

var abc = '0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z';
arr = abc.split(' ');

var arr_S = [];
for (var i = 0; i < arr.length; i++) {
    arr_S[arr[i]] = i;
};

// expected: 'RZ228', found: 'SA228'

for (var i = 0; i < n; i++) {

    str = readline();

    if (reg.test(str)) {
        for (var j = 1; /\d/.test(str[j]); j++) {};
        x = str.substring(1, j); // номер строки
        y = str.substring(j+1, str.length );
        var pos = parseInt(y); // числовой номер столбца
        var valpor = 26; // значение порядка числа в 26-ричной системе
        var por = 1; // порядок числа в 26-ричной системе

        while (valpor < pos) {
            por ++;
            valpor = valpor * 26;
        }

        for (var j = por; j >=1; j--) {
            for (var k = 2; k <= 26; k++) {
                if (Math.pow(26, j-1) * k > pos) {
                    out += arr[k-1];
                    pos -= Math.pow(26, j-1) * (k - 1);
                    break;
                };
                if (Math.pow(26, j-1) * k === pos) {
                    out += arr[k-2];
                    pos -= Math.pow(26, j-1) * (k-1);
                    break;
                };
            };
        };

        out += x + "\n";

    } else {
        x = str.match(/\d+/); // номер строки
        y = str.match(/[A-Z]+/);   // буквенный номер столбца
        var len = y[0].length;
        var posN = 0; // числовой номер столбца
        for (var j = len; j > 0; j--) {
            posN += arr_S[y[0].substring(len-j, len-j+1)] * Math.pow(26, j-1);
        };

        out += 'R' + x + 'C' + posN.toString() + "\n";

    }
};

print(out);

function main() {
  const count = readline();
  for (var i = 0; i < count; i++) {
      var view = readline();
      if (isRowColumnView(view)) {
          print(changeViewToExcel(view));
      } else {
          print(changeViewToCR(view));
      }
  }
}

main();

function isRowColumnView(str) {
    return /R\d+C\d+/i.test(str);
  }

  function changeViewToCR(str) {
    var indexOfNumber = 0;
    var numberArr = [];
    var column;
    for (var i = 0; i < str.length; i++) {
        var char = str[i];
        if (isNaN(char)) {
            numberArr.push(char.charCodeAt(0) - 64);
        } else {
            indexOfNumber = i;
            break;
        }
    }
    column = numberArr.reduce( (col, elem, i) => {
        return col += elem * Math.pow(26, numberArr.length - 1 - i);
    }, 0)
    return `R${str.slice(indexOfNumber)}C${column}`;
  }

  function changeViewToExcel(str) {
    var indexOfC = str.indexOf("C");
    var column = +str.slice(indexOfC + 1);
    var excelColumn = [];
    var sqrN = Math.floor(getBaseLog(26, column));
    var sqrnMax = sqrN;
    while (sqrN > -1) {
        var pow = Math.pow(26, sqrN);
        var tempNum = Math.floor(column/pow);
        //if (column % pow === 26 && tempNum === 1) {
        if (sqrN > 0 && tempNum === 1) {
            excelColumn.push("Z");
        } else  if (column % pow === 0 && sqrN !== 0){
            excelColumn.push("Z");
        } else if ((tempNum === 0 && sqrN === 0) || (sqrN !== sqrnMax && excelColumn[sqrnMax - sqrN -1] === "Z")) {

        } else {
            excelColumn.push(String.fromCharCode(tempNum + 64));
        }
        column -= tempNum * pow;
        sqrN--;
    }
    //excelColumn.push(String.fromCharCode(tempNum + 64));
    var row = str.slice(1, indexOfC);
    return `${excelColumn.join('')}${row}`;
  }

  function getBaseLog(x, y) {
    return Math.log(y) / Math.log(x);
  }

function a2c(a){
    var i, c = 0;
    for (i=0; i<a.length; i++){
        c += Math.pow(26, a.length-i-1) * (a.charCodeAt(i) - 65);
    }
    if (a.length > 1) c += Math.pow(26, a.length - 1);
    return c + 1;
}

function c2a(c){
    var q, r, a = '';

    c -= 1;
    if (c < 26) return String.fromCharCode(c + 65) + a;

    while (true){
        q = Math.floor(c / 26);
        r = c % 26;
        if (q == 0) {
            a = String.fromCharCode(r + 64) + a;
            break;
        }
        a = String.fromCharCode(r + 65) + a;
        c = q;
    }
    return a;
}

function convert(s){
    var i, temp;
    s = s.toUpperCase();

    if (/^[A-Z]{1,5}[1-9][0-9]*$/.test(s)) {
        for (i=0; i<s.length; i++){
            if (s.substr(i,1) < 'A'){
                break;
            }
        }
        return "R" + s.substr(i) + "C" + a2c(s.substr(0,i));
    }

    if (/^R[1-9][0-9]*C[1-9][0-9]*$/.test(s)) {
        temp = s.split("C");
        return c2a(temp[1]) + temp[0].substr(1);
    }

    return "Invalid format";
}

var n = readline();
for (var i=0; i<n; i++){
    print(convert(readline()));
}

var n = parseInt(readline());
const pattern = /([A-Z]+\d+){2}/;
const del1 = /R(\d+)C(\d+)/, del2 = /([A-Z]+)(\d+)/;
while(n--) {
    var line = readline();
    if(line.match(pattern)){
        var data = del1.exec(line);
        print(toStr(data[2]) + data[1]);
    }
    else {
        var data = del2.exec(line);
        print(`R${data[2]}C${toNum(data[1])}`);
    }
}

function toStr(num) {
    var res = "";
    while(num > 0) {
        var ans = num % 26;
        res = (ans ? String.fromCharCode(ans + 64) : "Z") + res;
        num = parseInt(num / 26);
    }
    return res;
}

function toNum(str) {
    var res = 0;
	for(var i = 0; i < str.length; i++) {
	    res += (str.charCodeAt(i) - 64) * Math.pow(26, str.length - i - 1);
	}
	return res;
}

var data = readline().split(" ");
var n = data[0];
var int = n.replace(/[^0-9]/g, " ").trim().split(" ");

function getNumToCol(num){
    var dividend = num;
    var columnName = "";
    var modulo;

    while (dividend > 0)
    {
        modulo = (dividend - 1) % 26;
        columnName = String.fromCharCode(65 + modulo).toString() + columnName;
        dividend = parseInt((dividend - modulo) / 26);
    }
    return  columnName;
}

function getColToNum(col) {
    var len = col.length;
    var number = 0;

    for (var i = 0, l = len; i < l; i++) {
        var mod = col[l - (i+1)].charCodeAt() - 64;
        var number = number + (Math.pow(26, i) * mod);
    }

    return Strung(number);
}

// RXCY
if (n[0] == "R" && int.length == 2) {
    print(getNumToCol(int[1]) + String(int[0]));
}
// Nomal
else if (/[A-Z]/.test(n[0]) && int.length == 1) {
    print("R" + int[0] + "C" + getColToNum(n[0].replace(/[0-9]/g, " ").split(" ")[0]));
}

// 1B   Электронные таблицы

var n = parseInt(readline());
//var input_line = readline().split(' ').map(Number);
//var n =  input_line[0];
//var m =  input_line[1];

var arr = [];
var out ='';
var reg = /^[R][\d]+[C][\d]+/;
var x, y;

var abc = '0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z';
arr = abc.split(' ');

var arr_S = [];
for (var i = 0; i < arr.length; i++) {
    arr_S[arr[i]] = i;
};

// expected: 'RZ228', found: 'SA228'

for (var i = 0; i < n; i++) {

    str = readline();

    if (reg.test(str)) {
        for (var j = 1; /\d/.test(str[j]); j++) {};
        x = str.substring(1, j); // номер строки
        y = str.substring(j+1, str.length );
        var pos = parseInt(y); // числовой номер столбца
        var valpor = 26; // значение порядка числа в 26-ричной системе
        var por = 1; // порядок числа в 26-ричной системе

        while (valpor < pos) {
            por ++;
            valpor = valpor * 26;
        }

        for (var j = por; j >=1; j--) {
            for (var k = 2; k <= 26; k++) {
                if (Math.pow(26, j-1) * k > pos) {
                    out += arr[k-1];
                    pos -= Math.pow(26, j-1) * (k - 1);
                    break;
                };
                if (Math.pow(26, j-1) * k === pos) {
                    if (j == 1) {
                        out += arr[k];
                    } else {
                        out += arr[k-1];
                    }
                    pos -= Math.pow(26, j-1) * (k-2);
                    break;
                };
            };
        };

        out += x + "\n";

    } else {
        x = str.match(/\d+/); // номер строки
        y = str.match(/[A-Z]+/);   // буквенный номер столбца
        var len = y[0].length;
        var posN = 0; // числовой номер столбца
        for (var j = len; j > 0; j--) {
            posN += arr_S[y[0].substring(len-j, len-j+1)] * Math.pow(26, j-1);
        };

        out += 'R' + x + 'C' + posN.toString() + "\n";

    }
};

print(out);

var c = readline(), s, m;

while(c--){
	s = readline();
	m = /^R(\d+)C(\d+)/.exec(s);

	if( m ){
		print( toChar(m[2]) + m[1] );
	}else{
		m = /^(\w+)(\d+)/.exec(s);
		print('R' + m[2] + 'C' + toNum(m[1]) );
	}
}

function toChar(num){
	var ret = '';
	var m = num%26;
	while( num > 26 ){
		ret = String.fromCharCode( m+64 ) +ret;
		num = (num - m)/26
		m = num%26
	}
	return String.fromCharCode( m+64 ) +ret;
}

function toNum(char){
	var l = char.length;
	var ret = 0;
	var t = 1;
	while(l--){
		ret += ( char.charCodeAt(l)-64 ) * t;
		t *= 26
	}
	return ret;
}

var n=parseInt(readline());
var regRC=/R(\d+)C(\d+)/;
var regSP=/([A-Z]+)([0-9]+)/;
for(var i=0;i<n;i++){
	var input=readline();
	var found=input.match(regRC);
	if( found!=null )
	{
		var r=found[1];
		var c=found[2];
		print(number2alpha(parseInt(c))+r);
	}else
	{
		var foundSP=input.match(regSP);
		if(foundSP!=null)
		{
			print('R'+foundSP[2]+'C'+alpha2number(foundSP[1]));
		}

	}

}

function number2alpha(num){
	var result;
	result=String.fromCharCode('A'.charCodeAt(0)+num%26-1);
	var a=Math.floor(num/26);
	if(a>=26)
	{
		result=number2alpha(a)+result;
	}else if(a!=0)
	{
		result=String.fromCharCode('A'.charCodeAt(0)+a-1)+result;
	}
	return result;
};

function alpha2number(alpha){
	var result=0;
	for(var i=0;i<alpha.length;i++){
		result+=(alpha.charCodeAt(i)-65+1)*Math.pow(26, alpha.length-1-i);
	}
	return result;
};

function baseToDec(baseRep, baseMap) {
    const baseSize = Object.keys(baseMap).length - 1;
    let res = 0;
    for (let i = 0; i < baseRep.length - 1; i++) {
        const w = baseRep[i];
        res = (res + baseMap[w]) * baseSize;
    }
    res = res + baseMap[baseRep[baseRep.length - 1]];
    return res;
}

function decToBase(num, baseMap) {
    const baseSize = Object.keys(baseMap).length - 1;

    const inverseBaseMap = {};
    for (let w of Object.keys(baseMap)) {
        inverseBaseMap[baseMap[w]] = w;
    }

    if (num === 0) {
        return inverseBaseMap[0];
    }

    let rep = [];

    while (num !== 0) {
        let rem = num % baseSize;
        rep.push(inverseBaseMap[rem]);
        num = (num - rem) / baseSize;
    }

    return rep.reverse().join("");
}

function rowColToStand(rowCol) {
    const RC = rowCol.match(/R(.*)C(.*)/);
    return { row: Number(RC[1]), col: Number(RC[2]) };
}

function standToRowCol(stand) {
    return `R${stand.row}C${stand.col}`;
}

const alphaBase = "0ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("").reduce((acc, curr, i) => {
    acc[curr] = i;
    return acc;
}, {});

function alphaToStand(alpha) {
    const RC = alpha.match(/([A-Z]*)([0-9]*)/);
    const alphaCol = RC[1];
    const row = Number(RC[2]);
    const col = baseToDec(alphaCol, alphaBase);
    return { row, col };
}

function standToAlpha(stand) {
    return `${decToBase(stand.col, alphaBase)}${stand.row}`;
}

process.stdin.read();

let line = "";
process.stdin.on("data", w => {
    line += w;
});

process.stdin.on("end", () => {
    const lines = line
        .split(/\r?\n/g)
        .filter(l => l.length !== 0)
        .slice(1);

    lines.forEach(line => {
        if (line.match(/^[A-Z]+[0-9]+$/)) {
            console.log(standToRowCol(alphaToStand(line)));
        }

        if (line.match(/^R[0-9]+C[0-9]+$/)) {
            console.log(standToAlpha(rowColToStand(line)));
        }
    });
});

var num2string = function (num) {
    var sLen = 1;
    var t = 26;
    while (num > t) {
        num -= t;
        sLen ++;
        t *= 26;
    }
    num --;
    var res = "";
    for (var i = 0; i < sLen; i ++) {
        res = String.fromCharCode(65 + num % 26) + res;
        num = parseInt(num / 26);
    }
    return res;
};

var string2num = function (s) {
    var sLen = s.length;
    var res = 0;
    var t = 26;
    for (var i = 0; i < sLen-1; i ++) {
        res += t;
        t *= 26;
    }
    res += 1;
    t = 1;
    for (var i = sLen-1; i >= 0; i --) {
        res += (s[i].charCodeAt() - 65) * t;
        t *= 26;
    }
    return res;
};

var check1 = function (s) {
    if (s[0] == 'R' && s[1].charCodeAt() <= 57) {
        var idx = s.indexOf("C");
        var num1 = parseInt(s.substring(1, idx));
        var num2 = parseInt(s.substring(idx+1));
        print(num2string(num2) + num1);
        return true;
    }
    else {
        return false;
    }
};

var check2 = function (s) {
    var idx = 0;
    for (idx = 0; idx < s.length; idx ++) {
        if (s[idx].charCodeAt() <= 57)
            break;
    }
    var subs = s.substring(0, idx);
    print("R" + s.substring(idx) + "C" + string2num(subs));
};

n = parseInt(readline());
for (var i = 0; i < n; i ++) {
    var s = readline();
    if (!check1(s))
        check2(s);
}

var data = readline().split(" ");
var n = data[0];
var int = n.replace(/[^0-9]/g, " ").trim().split(" ");

function getNumToCol(num){
    var dividend = num;
    var columnName = "";
    var modulo;

    while (dividend > 0)
    {
        modulo = (dividend - 1) % 26;
        columnName = String.fromCharCode(65 + modulo).toString() + columnName;
        dividend = parseInt((dividend - modulo) / 26);
    }
    return  columnName;
}

function getColToNum(col) {
    var len = col.length;
    var number = 0;

    for (var i = 0, l = len; i < l; i++) {
        var mod = col[l - (i+1)].charCodeAt() - 64;
        var number = number + (Math.pow(26, i) * mod);
    }

    return Strung(number);
}

// RXCY
if (n[0] == "R" && int.length == 2) {
    print(getNumToCol(int[1]) + String(int[0]));
}
// Nomal
else if (/[A-Z]/.test(n[0]) && int.length == 1) {
    print("R" + int[0] + "C" + getColToNum(n[0].replace(/[0-9]/g, " ").split(" ")[0]));
}
else {
    print(readline());
}

var pos = readline();
var array = [];

for (var i = 0; i < pos; i++) {
    array.push(readline());
}

for (var i = 0; i < array.length; i++) {
    var text = array[i];
    var pattern = /R[(0-9)]{1,10}C[(0-9)]{1,10}/;
    if (pattern.test(text)) {
        var row = 0;
        var col = 0;
        var separator = 0;
        for (var j = 0; j < text.length; j++) {
            if (text[j] == 'C') {
                separator = j;
            }
        }

        var row = parseInt(text.substring(0, separator).replace(/[^0-9]/g, ''));
        var col = parseInt(text.substring(separator, text.length).replace(/[^0-9]/g, ''));

        var colChar = '';
        for (var j = Math.floor(col / 26) - 1; j >= 0; j--) {
            if ((col / 26) < 1) {
                colChar += String.fromCharCode(col + 64);
                break;
            }

            colChar += String.fromCharCode(Math.floor(col / 26) + 64);
            col -= (26 * (j + 1));
        }

        var converted = colChar + row;
        print(converted);
    } else {
        var separator = 0;
        for (var j = 0; j < text.length; j++) {
            var number = parseInt(text[j]);
            if (number >= 0 && number <= 9) {
                separator = j;
                break;
            }
        }

        var row = parseInt(text.substring(separator, text.length));
        var col = text.substring(0, separator);
        var colNum = 0;
        var ascii = 64;
        col = col.split('').reverse();
        for (var j = 0; j < col.length; j++) {
            var char = col[j].toUpperCase().charCodeAt(0) - ascii;
            if (j === 0) {
                colNum += char;
            } else {
                colNum += (26 * j * char);
            }
        }

        var converted = 'R' + row + 'C' + colNum;
        print(converted);
    }
}

var a,b;
readline();

while(a=readline())print((b=a.match(/R(\d+)C(\d+)/))?M(b[2])+b[1]:(b=a.match(/^([A-Z]+)(\d+)$/),'R'+b[2]+'C'+N(b[1])));

function N(l){
  var n=l.length-1,i=v=0,c;
	for(;c=l.charCodeAt(i)-64;i++)v=v+Math.pow(26,n-i)*c;
	return v;
}

function M(l){
  var a='',b=String.fromCharCode;
  for(l--;l>26;l=parseInt(l/26))a=b(l%26+64)+a;
	return b(+l+64)+a;
}

// 1B   Электронные таблицы
/*
function main_1(){
    var n = parseInt(readline());
    var ans = 0;
    while (n--) {
        var nums = readline().split(' ').map(Number);
        ans += (nums[2] - nums[0] + 1) * (nums[3] - nums[1] + 1);
    }
    print(ans);
}

function main(){
    var line  = readline();
    //var line = prompt();
    var n = line.length;
    //alert(line);
    var m = 0;
    for(i=0;i<n;i+=2){
        for(j=i+1;j<n;j+=2){
            var ex = [line.slice(0, i), '(', line.slice(i,j) , ')' , line.slice(j)].join('');
            m = Math.max(m,eval(ex));
        }
    }
    print(m);
}
*/

var n = parseInt(readline());
//var input_line = readline().split(' ').map(Number);
//var n =  input_line[0];
//var m =  input_line[1];

var arr = [];
var out ='';
var reg = /^[R][\d]+[C][\d]+/;
var x, y;

var abc = '0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z';
arr = abc.split(' ');

var arr_S = [];
for (var i = 0; i < arr.length; i++) {
    arr_S[arr[i]] = i;
};
// RAA23R23C78
// AAA23

//R23C78

for (var i = 0; i < n; i++) {

    str = readline();

    if (reg.test(str)) {
        for (var j = 1; /\d/.test(str[j]); j++) {};
        x = str.substring(1, j); // номер строки
        y = str.substring(j+1, str.length );
        var pos = parseInt(y); // числовой номер столбца
        var valpor = 26; // значение порядка числа в 26-ричной системе
        var por = 1; // порядок числа в 26-ричной системе

        while (valpor < pos) {
            por ++;
            valpor = por * 26;
        }

        for (var j = por; j >=1; j--) {
            for (var k = 2; k <= 26; k++) {
                if (j * 26 * k > pos) {
                    out += arr[k-1];
                    pos -= j * (k - 1);
                    break;
                };
            };
        };

        out += x + "\n";

    } else {
        x = str.match(/\d+/); // номер строки
        y = str.match(/[A-Z]+/);   // буквенный номер столбца
        var len = y.length;
        var posN = 0; // числовой номер столбца
        for (var j = len; j >= 0; j--) {
            posN += arr_S[str[j]] * j * 26;
        };

        out += 'R' + x + 'C' + posN.toString() + "\n";

    }
};

print(out);

// 1B   Электронные таблицы

var n = parseInt(readline());
//var input_line = readline().split(' ').map(Number);
//var n =  input_line[0];
//var m =  input_line[1];

var arr = [];
var out ='';
var reg = /^[R][\d]+[C][\d]+/;
var x, y;

var abc = '0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z';
arr = abc.split(' ');

var arr_S = [];
for (var i = 0; i < arr.length; i++) {
    arr_S[arr[i]] = i;
};

// expected: 'RZ228', found: 'SA228'

for (var i = 0; i < n; i++) {

    str = readline();

    if (reg.test(str)) {
        for (var j = 1; /\d/.test(str[j]); j++) {};
        x = str.substring(1, j); // номер строки
        y = str.substring(j+1, str.length );
        var pos = parseInt(y); // числовой номер столбца
        var valpor = 26; // значение порядка числа в 26-ричной системе
        var por = 1; // порядок числа в 26-ричной системе

        while (valpor < pos) {
            por ++;
            valpor = valpor * 26;
        }

        for (var j = por; j >=1; j--) {
            for (var k = 2; k <= 26; k++) {
                if (Math.pow(26, j-1) * k > pos) {
                    out += arr[k-1];
                    pos -= Math.pow(26, j-1) * (k - 1);
                    break;
                };
                if (Math.pow(26, j-1) * k == pos) {
                    out += arr[k];
                    pos -= Math.pow(26, j-1) * k;
                    break;
                };
            };
        };

        out += x + "\n";

    } else {
        x = str.match(/\d+/); // номер строки
        y = str.match(/[A-Z]+/);   // буквенный номер столбца
        var len = y[0].length;
        var posN = 0; // числовой номер столбца
        for (var j = len; j > 0; j--) {
            posN += arr_S[y[0].substring(len-j, len-j+1)] * Math.pow(26, j-1);
        };

        out += 'R' + x + 'C' + posN.toString() + "\n";

    }
};

print(out);

// 1B   Электронные таблицы
/*
function main_1(){
    var n = parseInt(readline());
    var ans = 0;
    while (n--) {
        var nums = readline().split(' ').map(Number);
        ans += (nums[2] - nums[0] + 1) * (nums[3] - nums[1] + 1);
    }
    print(ans);
}

function main(){
    var line  = readline();
    //var line = prompt();
    var n = line.length;
    //alert(line);
    var m = 0;
    for(i=0;i<n;i+=2){
        for(j=i+1;j<n;j+=2){
            var ex = [line.slice(0, i), '(', line.slice(i,j) , ')' , line.slice(j)].join('');
            m = Math.max(m,eval(ex));
        }
    }
    print(m);
}
*/

var n = parseInt(readline());
//var input_line = readline().split(' ').map(Number);
//var n =  input_line[0];
//var m =  input_line[1];

var arr = [];
var out ='';
var reg = /^[R][\d]+[C][\d]+/;
var x, y;

var abc = '0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z';
arr = abc.split(' ');

var arr_S = [];
for (var i = 0; i < arr.length; i++) {
    arr_S[arr[i]] = i;
};
// RAA23R23C78
// AAA23

//R23C78

for (var i = 0; i < n; i++) {

    str = readline();

    if (reg.test(str)) {
        for (var j = 1; /\d/.test(str[j]); j++) {};
        x = str.substring(1, j); // номер строки
        y = str.substring(j+1, str.length );
        var pos = parseInt(y); // числовой номер столбца
        var valpor = 26; // значение порядка числа в 26-ричной системе
        var por = 1; // порядок числа в 26-ричной системе

        while (valpor < pos) {
            por ++;
            valpor = valpor * 26;
        }

        for (var j = por; j >=1; j--) {
            for (var k = 2; k <= 26; k++) {
                if (Math.pow(26, j-1) * k > pos) {
                    out += arr[k-1];
                    pos -= Math.pow(26, j-1) * (k - 1);
                    break;
                };
            };
        };

        out += x + "\n";

    } else {
        x = str.match(/\d+/); // номер строки
        y = str.match(/[A-Z][A-Z]/);   // буквенный номер столбца
        var len = y.length;
        var posN = 0; // числовой номер столбца
        for (var j = len; j > 0; j--) {
            posN += arr_S[str[len-j]] * Math.pow(26, j-1);
        };

        out += 'R' + x + 'C' + posN.toString() + "\n";

    }
};

print(out);

const strSettings=readline().trim();
const n=Number(strSettings);
const rexRXCY=new RegExp('R[0-9]+C[0-9]+');
var str='';
var row=0;
var col=0;
var i=0;
var arr=[];
var str2='';

function ColumnNumber(strColumn){   // Convert column name to number
    const strLetters='ABCDEFGHIJKLMNOPQRSTUVWXYZ';
    var intColumn=strLetters.search(strColumn[0])+1;
    for (var j=1;j<strColumn.length;j++){
        intColumn=intColumn*26;
        intColumn=intColumn+strLetters.search(strColumn[j])+1;
    }
    return intColumn;
}

function ColumnName(intColumn) {    // Convert column number to name
    const strLetters='ABCDEFGHIJKLMNOPQRSTUVWXYZ';
    var strColumn='';
    var intRemainder=0;
    do {
       intRemainder=intColumn%26;
       strColumn=strLetters[intRemainder-1]+strColumn;
       intColumn=intColumn-intRemainder;
       intColumn=intColumn/26;
    }
    while (intColumn>0);
    return strColumn;
}

for (i=1;i<=n;i++) {
    str=readline();
    if (str.search(rexRXCY)>=0){    // RXCY format
        //print('str:'+str);
        arr=str.split(/[A-Z]/);
        row=Number(arr[1]);
        col=Number(arr[2]);
        print(ColumnName(col)+String(row));
    } else {                        // ColRow format
        col=ColumnNumber(str.split(/[0-9]/)[0]);
        row=Number(String(str.match('[0-9]+')));
        print('R'+String(row)+'C'+String(col));
    }
}

//var fs = require('fs');

//var readline = (function () {
	//var file = fs.readFileSync('input.txt', 'utf-8').split('\n');
	//return function () {
		//return file.shift()
	//}
//})();
//var print = console.log;

var numberOfLines = Number(readline());

for (var i = 0; i < numberOfLines; i++) {
    var line = readline();
    if (line[0] === 'R') {
        line = line.slice(1).split('C');
        var rowsTmp = Number(line[1]);
        var cols = Number(line[0]);
        var rows = '';

        while (rowsTmp > 0) {
            var currentCharCode = 64 + (rowsTmp % 26 === 0 ? 26 : rowsTmp % 26);

            rows = String.fromCharCode(currentCharCode) + rows;
            rowsTmp = Math.floor(rowsTmp / 26);
        }

        print(rows + cols);

    } else {
        var tmp = /([A-Z]+)(\d+)/.exec(line);
        var cols = tmp[2];
        var rowsTmp = tmp[1];
        var rows = 0;

        for (var j = 0; j < rowsTmp.length; j++) {
            rows = rows * 26 + (rowsTmp[j].charCodeAt(0) - 64)
        }

        print('R' + cols + 'C' + rows);
    }
}

const n = readline();

const lines = [];
for(var i=0;i<n;i++) {
    lines.push(readline());
}

const CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

function numToCol(num) {
    var n = num;
    var result = "";
    do {
        result = CHARS[ (n-1) % 26 ] + result;
        n = Math.floor( (n-1) / 26 );
    } while(n > 0);
    return result;
}

function colToNum(col) {
    var num = 0;
    for(var i=col.length - 1;i > -1;i--) {
        const chr = col[i];
        const n = Math.pow(26, col.length - i - 1) * (CHARS.indexOf(chr) + 1);
        num += n;
    }
    return num;
}

function trans(coord) {
    if(/R\d+C\d+/.test(coord)) {
        var row = coord.match(/\d+/)[0];
        var col = coord.match(/\d+$/)[0];
        return  numToCol(col) + row;
    } else {
        var col = coord.match(/[A-Z]+/)[0];
        var row = coord.match(/\d+/)[0];
        return  'R' + row + 'C' + colToNum(col);
    }
}

for(var i in lines) {
    const line = trans(lines[i]);
    print(line);
}

function typeOf(cell) {
    if (cell[0] === 'R') {
        if (isNaN(cell[1])) {
            return 1;
        } else {
            if (cell.indexOf("C") !== -1)
                return 2;
            else {
                return 1;
            }
        }
    } else {
        return 1;
    }
}

function convert_2_to_1(cell) {
    'use strict';
    let row = "";
    let column = "";
    let stringColumn = "";
    let i = 1;

    while (cell[i] !== 'C')
        row += cell[i++];

    i++;

    while (i < cell.length)
        column += cell[i++];

    column = Number(column);

    while (column !== 0) {
        let mod = column % 26;
        if (mod === 0)
            stringColumn = String.fromCharCode(90) + stringColumn;
        else
            stringColumn = String.fromCharCode(64 + mod) + stringColumn;

        column = Math.floor(column / 26);
    }

    return stringColumn + row.toString();
}

function convert_1_to_2(cell) {
    'use strict';
    let i = 0;
    let row = "";
    let column = "";
    let columnBase10 = 0;
    let columnBase26 = [];
    let result = "";

    while (isNaN(cell[i])) {
        let code = cell.charCodeAt(i);
        columnBase26.push(code - 64);
        i++;
    }

    columnBase26.map((item, index, arr) => {
        columnBase10 += item * Math.pow(26, arr.length - index - 1);
    });

    column = columnBase10.toString();

    while (i < cell.length) {
        row += (cell[i]);
        i++;
    }

    result = "R" + row + "C" + column;
    return result;
}

var testNumber = readline();

// while(testNumber !== 0){
//     let cell = readline();
//     if(typeOf(cell) === 1)
//     {
//         print(convert_1_to_2(cell));
//     }
//     else{
//         print(convert_2_to_1(cell));
//     }

//     testNumber--;
// }

var c = readline(), s, m;

while(c--){
	s = readline();
	m = /^R(\d+)C(\d+)/.exec(s);

	if( m ){
		print( toChar(m[2]) + m[1] );
	}else{
		m = /^(\w+)(\d+)/.exec(s);
		print('R' + m[2] + 'C' + toNum(m[1]).toString(10) );
	}
}

function toChar(num){
	var ret = '';
	var m = num%26;
	while( num > 26 ){
		ret = String.fromCharCode( m+64 ) +ret;
		num = (num - m)/26
		m = num%26
	}
	return String.fromCharCode( m+64 ) +ret;
}

function toNum(char){
	var l = char.length;
	var ret = 0;
	var t = 1;
	while(l--){
		ret += ( char.charCodeAt(l)-64 ) * t;
		t *= 26
	}
	return ret;
}

// 1B   Электронные таблицы

var n = parseInt(readline());
//var input_line = readline().split(' ').map(Number);
//var n =  input_line[0];
//var m =  input_line[1];

var arr = [];
var out ='';
var reg = /^[R][\d]+[C][\d]+/;
var x, y;

var abc = '0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ';
arr = abc.split(' ');

var arr_S = [];
for (var i = 0; i < arr.length; i++) {
    arr_S[arr[i]] = i;
};

// expected: 'RZ228', found: 'SA228'

for (var i = 0; i < n; i++) {

    str = readline();

    if (reg.test(str)) {
        for (var j = 1; /\d/.test(str[j]); j++) {};
        x = str.substring(1, j); // номер строки
        y = str.substring(j+1, str.length );
        var pos = parseInt(y); // числовой номер столбца
        var valpor = 27; // значение порядка числа в 26-ричной системе
        var por = 1; // порядок числа в 26-ричной системе

        while (valpor-1 < pos) {
            por ++;
            valpor = valpor * 27;
        }

        for (var j = por; j >=1; j--) {
            for (var k = 2; k <= 26; k++) {
                if (Math.pow(26, j-1) * k > pos) {
                    out += arr[k-1];
                    pos -= Math.pow(26, j-1) * (k - 1);
                    break;
                };
                if (Math.pow(26, j-1) * k === pos) {
                    if (j === 1) {
                        out += arr[k];
                    } else {
                        out += arr[k-1];
                    };
                    pos -= Math.pow(26, j-1) * (k-1);
                    break;
                };
            };
        };

        out += x + "\n";

    } else {
        x = str.match(/\d+/); // номер строки
        y = str.match(/[A-Z]+/);   // буквенный номер столбца
        var len = y[0].length;
        var posN = 0; // числовой номер столбца
        for (var j = len; j > 0; j--) {
            posN += arr_S[y[0].substring(len-j, len-j+1)] * Math.pow(26, j-1);
        };

        out += 'R' + x + 'C' + posN.toString() + "\n";

    }
};

print(out);

// 1B   Электронные таблицы
/*
function main_1(){
    var n = parseInt(readline());
    var ans = 0;
    while (n--) {
        var nums = readline().split(' ').map(Number);
        ans += (nums[2] - nums[0] + 1) * (nums[3] - nums[1] + 1);
    }
    print(ans);
}

function main(){
    var line  = readline();
    //var line = prompt();
    var n = line.length;
    //alert(line);
    var m = 0;
    for(i=0;i<n;i+=2){
        for(j=i+1;j<n;j+=2){
            var ex = [line.slice(0, i), '(', line.slice(i,j) , ')' , line.slice(j)].join('');
            m = Math.max(m,eval(ex));
        }
    }
    print(m);
}
*/

var n = parseInt(readline());
//var input_line = readline().split(' ').map(Number);
//var n =  input_line[0];
//var m =  input_line[1];

var arr = [];
var out ='';
var reg = /^[R][\d]+[C][\d]+/;
var x, y;

var abc = '0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z';
arr = abc.split(' ');

var arr_S = [];
for (var i = 0; i < arr.length; i++) {
    arr_S[arr[i]] = i;
};
// RAA23R23C78
// AAA23

//R23C78

for (var i = 0; i < n; i++) {

    str = readline();

    if (reg.test(str)) {
        for (var j = 1; /\d/.test(str[j]); j++) {};
        x = str.substring(1, j); // номер строки
        y = str.substring(j+1, str.length );
        var pos = parseInt(y); // числовой номер столбца
        var valpor = 26; // значение порядка числа в 26-ричной системе
        var por = 1; // порядок числа в 26-ричной системе

        while (valpor < pos) {
            por ++;
            valpor = por * 26;
        }

        for (var j = por; j >=1; j--) {
            for (var k = 2; k <= 26; k++) {
                if (j * 26 * k > pos) {
                    out += arr[k-1];
                    pos -= j * 26 * (k - 1);
                    break;
                };
            };
        };

        out += x + "\n";

    } else {
        x = str.match(/\d+/); // номер строки
        y = str.match(/[A-Z]+/);   // буквенный номер столбца
        var len = y.length;
        var posN = 0; // числовой номер столбца
        for (var j = len; j > 0; j--) {
            posN += arr_S[str[j]] * j * 26;
        };

        out += 'R' + x + 'C' + posN.toString() + "\n";

    }
};

print(out);

// http://codeforces.com/problemset/problem/1/B
// B. Электронные таблицы
'use strict';

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

const input = [];
rl.on('line', (line) => { input.push(line); });

rl.on('close', function () {
  const BASE = 26;
  const UTF8_SHIFT = 'A'.charCodeAt(0) - 1;

  for (let i = 1; i < input.length; i++) {

    let blocks = [];
    let block = '';
    let lastChar = null;

    for (let j = 0; j < input[i].length; j++) {
      if (isNumeric(lastChar) !== isNumeric(input[i][j])) {
        blocks.push(block);
        block = '';
      }
      lastChar = input[i][j];
      block += input[i][j];
    }
    blocks.push(block);

    if (blocks.length === 2) {

      let column = blocks[0].split('').reduce(function (result, elem, index, arr) {
        result += (elem.charCodeAt(0) - UTF8_SHIFT) * Math.pow(BASE, arr.length - index - 1);
        return result;
      }, 0)
      console.log('R' + blocks[1] + 'C' + column);

    } else {

      let column = +blocks[3];
      let columnChars = [];
      console.log(column);
      while (column > 0) {
        column--;
        columnChars.push(String.fromCharCode(UTF8_SHIFT + column % BASE + 1));
        column = Math.floor(column / BASE);
      }
      console.log(columnChars.reverse().join('') + blocks[1]);

    }
  }
});

function isNumeric(n) {
  return !isNaN(parseFloat(n)) && isFinite(n);
}

const n = readline();

const lines = [];
for(var i=0;i<n;i++) {
    lines.push(readline());
}

const CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

function numToCol(num) {
    var n = num;
    var result = "";
    do {
        result = CHARS[ (n-1) % 26 ] + result;
        n = Math.floor( (n-1) / 26 );
    } while(n > 0);
    return result;
}

function colToNum(col) {
    var num = 0;
    for(var i=col.length - 1;i > -1;i--) {
        const chr = col[i];
        const n = Math.pow(26, col.length - i - 1) * (CHARS.indexOf(chr) + 1);
        console.log(n);
        num += n;
    }
    return num;
}

function trans(coord) {
    if(/R\d+C\d+/.test(coord)) {
        const row = coord.match(/\d+/)[0];
        const col = coord.match(/\d+$/)[0];
        return  numToCol(col) + row;
    } else {
        const col = coord.match(/[A-Z]+/)[0];
        const row = coord.match(/\d+/)[0];
        return  'R' + row + 'C' + colToNum(col);
    }
}

for(var i in lines) {
    const line = lines[i];
    print(line);
}

var c = readline(), s, m;

while(c--){
	s = readline();
	m = /^R(\d+)C(\d+)/.exec(s);

	if( m ){
		print( toChar(m[2]) + m[1] );
	}else{
		m = /^(\w+)(\d+)/.exec(s);
		print('R' + m[2] + 'C' + toNum(m[1]) );
	}
}

function toChar(num){
	var ret = '';
	var m = num%26;
	while( num > 26 ){
		ret = String.fromCharCode( m+64 ) +ret;
		num = (num - m)/26
		m = num%26
	}
	return String.fromCharCode( m+64 ) +ret;
}

function toNum(char){
	var l = char.length;
	var ret = 0;
	var t = 1;
	while(l--){
		ret += ( char.charCodeAt(l)-64 ) * t;
		t *= 26
	}
	return ret;
}

// 1B   Электронные таблицы

var n = parseInt(readline());
//var input_line = readline().split(' ').map(Number);
//var n =  input_line[0];
//var m =  input_line[1];

var arr = [];
var out ='';
var reg = /^[R][\d]+[C][\d]+/;
var x, y;

var abc = '0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ';
arr = abc.split(' ');

var arr_S = [];
for (var i = 0; i < arr.length; i++) {
    arr_S[arr[i]] = i;
};

// expected: 'RZ228', found: 'SA228'

for (var i = 0; i < n; i++) {

    str = readline();

    if (reg.test(str)) {
        for (var j = 1; /\d/.test(str[j]); j++) {};
        x = str.substring(1, j); // номер строки
        y = str.substring(j+1, str.length );
        var pos = parseInt(y); // числовой номер столбца
        var valpor = 26; // значение порядка числа в 26-ричной системе
        var por = 1; // порядок числа в 26-ричной системе

        while (valpor < pos) {
            por ++;
            valpor = valpor * 26;
        }

        for (var j = por; j >=1; j--) {
            for (var k = 2; k <= 27; k++) {
                if (Math.pow(26, j-1) * k > pos) {
                    out += arr[k-1];
                    pos -= Math.pow(26, j-1) * (k - 1);
                    break;
                };
                if (Math.pow(26, j-1) * k === pos) {
                    if (j === 1) {
                        out += arr[k];
                    } else {
                        out += arr[k-1];
                    };
                    pos -= Math.pow(26, j-1) * (k-1);
                    break;
                };
            };
        };

        out += x + "\n";

    } else {
        x = str.match(/\d+/); // номер строки
        y = str.match(/[A-Z]+/);   // буквенный номер столбца
        var len = y[0].length;
        var posN = 0; // числовой номер столбца
        for (var j = len; j > 0; j--) {
            posN += arr_S[y[0].substring(len-j, len-j+1)] * Math.pow(26, j-1);
        };

        out += 'R' + x + 'C' + posN.toString() + "\n";

    }
};

print(out);

'use strict';process.stdin.resume();process.stdin.setEncoding('utf-8');
let _iS = '',_cL = 0; process.stdin.on('data', _iSi => _iS += _iSi);
process.stdin.on('end', _ => {_iS = _iS.trim().split('\n').map(s => s.trim());main()});
const readline = () => _iS[_cL++];
//////////

const main = () => {
    const count = parseInt(readline());

    for(let i = 0; i < count; i++){
        console.log(transform(readline()));
    }
}

const transform = string => {
    if(string[0] == "R") {
        const args = string.split('C');
        const rowNumber = parseInt(args[0].slice(1));
        const colNumber = parseInt(args[1]);

        const base26 = colNumber.toString(26);
        const colCode = base26.split('').map(char => {
            const code = (isNaN(char) ? char.charCodeAt(0) - 87 : parseInt(char)) + 64
            return String.fromCharCode(code);
        }).join('')

        return `${colCode}${rowNumber}`;
    } else {
        const columnCode = string.replace(/[0-9]/g, '');
        const rowNumber = string.replace(/[A-Z]/g, '');

        const base26 = columnCode.split('').map(char =>
            (char.charCodeAt(0) - 64).toString(26)).join('')
        const base10 = parseInt(base26, 26);

        return `R${rowNumber}C${base10}`;
    }
};

const readline = require('readline');
const rl = readline.createInterface({
	input: process.stdin,
	output: process.stdout,
	terminal: false
});

const abcChars = '_ABCDEFGHIGKLMNOPQRSTUVWXYZ';
const dec2abc = dec => {
	let d = dec;
	let res = '';

	while (d > 0) {
		const mod = d % 26;
		res = abcChars[mod === 0 ? 26 : mod] + res;
		d = Math.floor(d / 26) - (mod === 0 ? 1 : 0);
	}

	return res;
};
const abc2dec = abc => {
	let res = 0;

	for (let i = 0; i < abc.length; i++) {
		res += abcChars.indexOf(abc[i]);
		if (i !== abc.length - 1) {
			res *= 26;
		}
	}

	return res;
};

let n, counter = 0;
const res = [];

rl.on('line', function (line) {
	if (!n) {
		n = parseInt(line);
	} else {
		const rc = line.match(/R(\d+)C(\d+)/);
		if (rc) {
			res.push(dec2abc(parseInt(rc[2])) + rc[1]);
		} else {
			const regular = line.match(/([^\d]+)(\d+)/);
			res.push('R' + regular[2] + 'C' + abc2dec(regular[1]));
		}

		counter++;
		if (counter === n) {
			for (let i = 0; i < res.length; i++) {
				console.log(res[i]);
			}
			rl.close();
		}
	}
});

// 1B   Электронные таблицы

var n = parseInt(readline());
//var input_line = readline().split(' ').map(Number);
//var n =  input_line[0];
//var m =  input_line[1];

var arr = [];
var out ='';
var reg = /^[R][\d]+[C][\d]+/;
var x, y;

var abc = '0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z';
arr = abc.split(' ');

var arr_S = [];
for (var i = 0; i < arr.length; i++) {
    arr_S[arr[i]] = i;
};

// expected: 'RZ228', found: 'SA228'

for (var i = 0; i < n; i++) {

    str = readline();

    if (reg.test(str)) {
        for (var j = 1; /\d/.test(str[j]); j++) {};
        x = str.substring(1, j); // номер строки
        y = str.substring(j+1, str.length );
        var pos = parseInt(y); // числовой номер столбца
        var valpor = 26; // значение порядка числа в 26-ричной системе
        var por = 1; // порядок числа в 26-ричной системе

        while (valpor < pos) {
            por ++;
            valpor = valpor * 26;
        }

        for (var j = por; j >=1; j--) {
            for (var k = 2; k <= 26; k++) {
                if (Math.pow(26, j-1) * k > pos) {
                    out += arr[k-1];
                    pos -= Math.pow(26, j-1) * (k - 1);
                    break;
                };
                if (Math.pow(26, j-1) * k === pos) {
                    if (j == 1) {
                        out += arr[k];
                    } else {
                        out += arr[k-1];
                    };
                    pos -= Math.pow(26, j-1) * (k-2);
                    break;
                };
            };
        };

        out += x + "\n";

    } else {
        x = str.match(/\d+/); // номер строки
        y = str.match(/[A-Z]+/);   // буквенный номер столбца
        var len = y[0].length;
        var posN = 0; // числовой номер столбца
        for (var j = len; j > 0; j--) {
            posN += arr_S[y[0].substring(len-j, len-j+1)] * Math.pow(26, j-1);
        };

        out += 'R' + x + 'C' + posN.toString() + "\n";

    }
};

print(out);

var data = readline().split(" ");
var n = data[0];
var int = n.replace(/[^0-9]/g, " ").trim().split(" ");

function getNumToCol(num){
    var dividend = num;
    var columnName = "";
    var modulo;

    while (dividend > 0)
    {
        modulo = (dividend - 1) % 26;
        columnName = String.fromCharCode(65 + modulo).toString() + columnName;
        dividend = parseInt((dividend - modulo) / 26);
    }
    return  columnName;
}

function getColToNum(col) {
    var len = col.length;
    var number = 0;

    for (var i = 0, l = len; i < l; i++) {
        var mod = col[l - (i+1)].charCodeAt() - 64;
        var number = number + (Math.pow(26, i) * mod);
    }

    return Strung(number);
}

// RXCY
if (n[0] == "R" && int.length == 2) {
    print(getNumToCol(int[1]) + String(int[0]));
}
// Nomal
else if (/[A-Z]/.test(n[0]) && int.length == 1) {
    print("R" + int[0] + "C" + getColToNum(n[0].replace(/[0-9]/g, " ").split(" ")[0]));
}
else {
    print(readline());
}

var n = readline();
var coord;
var match;

for (var i=0; i<n; i++) {
    coord = readline();

    match = coord.match(/^([A-Z]*)(\d*)$/);
    if (match) {
        print('R'+ match[2] + 'C' + toNumber(match[1]));
    } else {
        match = coord.match(/^R(\d*)C(\d*)$/);
        print(toChar(parseInt(match[2])) + match[1]);
    }
}

function toNumber(str) {
    var l = str.length,
        ret = 0,
        mul = 1;

    while (l--) {
        ret += mul * (str.charCodeAt(l) - 64);
        mul *= 26;
    }

    return ret;
}

function toChar(num) {
    var ret = '';

    while (num > 0) {
        c = num % 26;
        ret = String.fromCharCode(c + 64) + ret;
        num = Math.floor(num/26);
    }

    return ret;
}

var c = readline(), s, m;

while(c--){
	s = readline();
	m = /^R(\d+)C(\d+)/.exec(s);

	if( m ){
		print( toChar(m[2]) + m[1] );
	}else{
		m = /^([A-Z]+)(\d+)/.exec(s);
		print('R' + m[2] + 'C' + toNum(m[1]).toString(10) );
	}
}

function toChar(num){
	var ret = '';
	var m = num%26;
	while( num > 26 ){
		ret = String.fromCharCode( m+64 ) +ret;
		num = (num - m)/26
		m = num%26
	}
	return String.fromCharCode( m+64 ) +ret;
}

function toNum(char){
	var l = char.length;
	var ret = 0;
	var t = 1;
	while(l--){
		ret += ( char.charCodeAt(l)-64 ) * t;
		t *= 26
	}
	return ret;
}

function baseToDec(baseRep, baseMap) {
    const baseSize = Object.keys(baseMap).length - 1;
    let res = 0;
    for (let i = 0; i < baseRep.length - 1; i++) {
        const w = baseRep[i];
        res = (res + baseMap[w]) * baseSize;
    }
    res = res + baseMap[baseRep[baseRep.length - 1]];
    return res;
}

function decToBase(num, baseMap) {
    const baseSize = Object.keys(baseMap).length - 1;

    const inverseBaseMap = {};
    for (let w of Object.keys(baseMap)) {
        inverseBaseMap[baseMap[w]] = w;
    }

    if (num === 0) {
        return inverseBaseMap[0];
    }

    let rep = [];

    while (num !== 0) {
        let rem = num % baseSize;
        rem = rem === 0 ? baseSize : rem;
        rep.push(inverseBaseMap[rem]);
        num = (num - rem) / baseSize;
    }

    return rep.reverse().join("");
}

function rowColToStand(rowCol) {
    const RC = rowCol.match(/R(.*)C(.*)/);
    return { row: Number(RC[1]), col: Number(RC[2]) };
}

function standToRowCol(stand) {
    return `R${stand.row}C${stand.col}`;
}

const alphaBase = "_ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("").reduce((acc, curr, i) => {
    acc[curr] = i;
    return acc;
}, {});

function alphaToStand(alpha) {
    const RC = alpha.match(/([A-Z]*)([0-9]*)/);
    const alphaCol = RC[1];
    const row = Number(RC[2]);
    const col = baseToDec(alphaCol, alphaBase);
    return { row, col };
}

function standToAlpha(stand) {
    return `${decToBase(stand.col, alphaBase)}${stand.row}`;
}

process.stdin.read();

process.stdin.on("data", w => {
    const lines = w
        .toString()
        .trim()
        .split("\n");
    lines.forEach(line => {
        if (line.match(/^[A-Z]+[0-9]+$/)) {
            console.log(standToRowCol(alphaToStand(line)));
        }

        if (line.match(/^R[0-9]+C[0-9]+$/)) {
            console.log(standToAlpha(rowColToStand(line)));
        }
    });
});

const CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

function numToCol(num) {
    var n = num;
    var result = "";
    do {
        result = CHARS[ (n-1) % 26 ] + result;
        n = Math.floor( (n-1) / 26 );
    } while(n > 0);
    return result;
}

function colToNum(col) {
    var num = 0;
    for(var i=col.length - 1;i > -1;i--) {
        const chr = col[i];
        const n = Math.pow(26, col.length - i - 1) * (CHARS.indexOf(chr) + 1);
        num += n;
    }
    return num;
}

function trans(coord) {
    if(/^[A-Z]+\d+$/.test(coord)) {
        var col = coord.match(/[A-Z]+/)[0];
        var row = coord.match(/\d+/)[0];
        return  'R' + row + 'C' + colToNum(col);
    } else {
        var row = coord.match(/\d+/)[0];
        var col = coord.match(/\d+$/)[0];
        return  numToCol(col) + row;
    }
}

const n = readline();

while(line = readline()) {
    print( trans(line));
}

//var fs = require('fs');

//var readline = (function () {
    //var file = fs.readFileSync('input.txt', 'utf-8').split('\n');
    //return function () {
        //return file.shift()
    //}
//})();
//var print = console.log;

var numberOfLines = Number(readline());

for (var i = 0; i < numberOfLines; i++) {
    var line = readline();
    if (line[0] === 'R') {
        line = line.slice(1).split('C');
        var rowsTmp = Number(line[1]);
        var cols = Number(line[0]);
        var rows = '';

        while (rowsTmp > 0) {
            var currentCharCode = 64 + (rowsTmp % 26);
            rows = String.fromCharCode(currentCharCode) + rows;
            rowsTmp = Math.floor(rowsTmp / 26);
        }

        print(rows + cols);

    } else {
        var tmp = /([A-Z]+)(\d+)/.exec(line);
        var cols = tmp[2];
        var rowsTmp = tmp[1];
        var rows = 0;

        for (var j = 0; j < rowsTmp.length; j++) {
            rows = rows * 26 + (rowsTmp[j].charCodeAt(0) - 64)
        }

        print('R' + cols + 'C' + rows);
    }
}

function baseToDec(baseRep, baseMap) {
    const baseSize = Object.keys(baseMap).length - 1;
    let res = 0;
    for (let i = 0; i < baseRep.length - 1; i++) {
        const w = baseRep[i];
        res = (res + baseMap[w]) * baseSize;
    }
    res = res + baseMap[baseRep[baseRep.length - 1]];
    return res;
}

function decToBase(num, baseMap) {
    const baseSize = Object.keys(baseMap).length - 1;

    const inverseBaseMap = {};
    for (let w of Object.keys(baseMap)) {
        inverseBaseMap[baseMap[w]] = w;
    }

    if (num === 0) {
        return inverseBaseMap[0];
    }

    let rep = [];

    while (num !== 0) {
        let rem = num % baseSize;
        rem = rem === 0 ? baseSize : rem;
        rep.push(inverseBaseMap[rem]);
        num = (num - rem) / baseSize;
    }

    return rep.reverse().join("");
}

function rowColToStand(rowCol) {
    const RC = rowCol.match(/R(.*)C(.*)/);
    return { row: Number(RC[1]), col: Number(RC[2]) };
}

function standToRowCol(stand) {
    return `R${stand.row}C${stand.col}`;
}

const alphaBase = "_ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("").reduce((acc, curr, i) => {
    acc[curr] = i;
    return acc;
}, {});

function alphaToStand(alpha) {
    const RC = alpha.match(/([A-Z]*)([0-9]*)/);
    const alphaCol = RC[1];
    const row = Number(RC[2]);
    const col = baseToDec(alphaCol, alphaBase);
    return { row, col };
}

function standToAlpha(stand) {
    return `${decToBase(stand.col, alphaBase)}${stand.row}`;
}

process.stdin.read();

process.stdin.on("data", w => {
    const lines = w
        .toString()
        .trim()
        .split(/\r?\n/);

    lines.forEach(line => {
        if (line.match(/^[A-Z]+[0-9]+$/)) {
            console.log(standToRowCol(alphaToStand(line)));
        }

        if (line.match(/^R[0-9]+C[0-9]+$/)) {
            console.log(standToAlpha(rowColToStand(line)));
        }
    });
});

var A = 'A'.charCodeAt(0);
var Z = 'Z'.charCodeAt(0);
var D = Z - A + 1;

function toABS (n) {
	if (n >= D) {
		return toABS(Math.floor(n / D) - 1) + toABS(n % D);
	} else {
		return String.fromCharCode(A + n);
	}
}

function to123 (s) {
	var n = 0;
	for (var i = 0; i < s.length; i++) {
		n += (s.charCodeAt(i) - A - 1) * Math.pow(D, s.length - i - 1);
	}
	return n;
}

;(function () {

	var n = +readline();

	while (n--) {
		var s = readline();
		var r = /^R(\d+)C(\d+)/.exec(s);

		if (r) {
			print(toABS((+r[2]) - 1) + r[1]);
		} else {
			r = /^([A-Z]+)([0-9]+)/.exec(s);
			print('R' + r[2] + 'C' + to123(r[1]));
		}
	}

}).call(this);

var n = readline();
var str;
var sub1,sub2;
var alf = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

var res;

for (var i = 0; i < n; i++){
    str = readline();
    var re1 = /[R]\d+[C]\d+/g;
    var re2 = /\d+/g;
    var re4 = /\d+/;
    var re3 = /[A-Z]+/g;
    res = re1.exec(str);

    if (res != null){
        sub1 = re2.exec(str);
        sub2 = re2.exec(str);
        if (sub2 > 26) sub2--;
        res = "";
        while(sub2/26>1){
            res = alf[sub2%26]+res;
            sub2 = Math.floor(sub2/26);
             if (sub2 > 26) sub2--;
        }
        res = alf[--sub2]+res;
        print(res+sub1);
    }
    else {
        sub = re3.exec(str);
        res = 0;
        sub = sub + "";
        var l = sub.length;
        for (var j = 0; j < l; j++){
            res += (alf.indexOf(sub[j])+1) * Math.pow(26,l-j-1)
        }
        sub = re4.exec(str);
        print("R" + sub + "C" + res);
    }
}

// 1B   Электронные таблицы

var n = parseInt(readline());
//var input_line = readline().split(' ').map(Number);
//var n =  input_line[0];
//var m =  input_line[1];

var arr = [];
var out ='';
var reg = /^[R][\d]+[C][\d]+/;
var x, y;

var abc = '0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ';
arr = abc.split(' ');

var arr_S = [];
for (var i = 0; i < arr.length; i++) {
    arr_S[arr[i]] = i;
};

// expected: 'RZ228', found: 'SA228'

for (var i = 0; i < n; i++) {

    str = readline();

    if (reg.test(str)) {
        for (var j = 1; /\d/.test(str[j]); j++) {};
        x = str.substring(1, j); // номер строки
        y = str.substring(j+1, str.length );
        var pos = parseInt(y); // числовой номер столбца
        var valpor = 26; // значение порядка числа в 26-ричной системе
        var por = 1; // порядок числа в 26-ричной системе

        while (valpor < pos) {
            por ++;
            valpor = valpor * 26;
        }

        for (var j = por; j >=1; j--) {
            for (var k = 2; k <= 26; k++) {
                if (Math.pow(26, j-1) * k > pos) {
                    out += arr[k-1];
                    pos -= Math.pow(26, j-1) * (k - 1);
                    break;
                };
                if (Math.pow(26, j-1) * k === pos) {
                    if (j === 1) {
                        out += arr[k];
                    } else {
                        out += arr[k-2];
                    };
                    pos -= Math.pow(26, j-1) * (k-2);
                    break;
                };
            };
        };

        out += x + "\n";

    } else {
        x = str.match(/\d+/); // номер строки
        y = str.match(/[A-Z]+/);   // буквенный номер столбца
        var len = y[0].length;
        var posN = 0; // числовой номер столбца
        for (var j = len; j > 0; j--) {
            posN += arr_S[y[0].substring(len-j, len-j+1)] * Math.pow(26, j-1);
        };

        out += 'R' + x + 'C' + posN.toString() + "\n";

    }
};

print(out);

var count = readline();
  while(count--){
    s = readline();
    m = /^R(\d+)C(\d+)/.exec(s);
    if(m){
      print( toChar(m[2]) + m[1]);
    }else{
      m = /^([A-Z]+)(\d+)/.exec(s);
      print( 'R' + m[2] + 'C' + toNum( m[1]) );
    }

  }

  function toChar(num){
    var ret = '';
    var t
    while(num>0){
      var u = num % 26;
      num = Math.floor( num/26 );
      ret = String.fromCharCode(u+64) + ret;
    }
    return ret;

  }
  function toNum(char){
	var l = char.length;
	var ret = 0;
	var t = 1;
	while(l--){
		ret += ( char.charCodeAt(l)-64 ) * t;
		t *= 26
	}
	return ret;
}

var n=parseInt(readline());
var regRC=/R(\d+)C(\d+)/;
var regSP=/([A-Z]+)([0-9]+)/;
for(var i=0;i<n;i++){
	var input=readline();
	var found=input.match(regRC);
	if( found!=null )
	{
		var r=found[1];
		var c=found[2];
		print(number2alpha(parseInt(c))+r);
	}else
	{
		var foundSP=input.match(regSP);
		if(foundSP!=null)
		{
			print('R'+foundSP[2]+'C'+alpha2number(foundSP[1]));
		}

	}

}

function number2alpha(num){
	var result;
	result=String.fromCharCode('A'.charCodeAt(0)+num%26);
	var a=Math.floor(num/26);
	if(a>=26)
	{
		result=number2alpha(a)+result;
	}else if(a!=0)
	{
		result=String.fromCharCode('A'.charCodeAt(0)+a)+result;
	}
	return result;
};

function alpha2number(alpha){
	var result=0;
	for(var i=alpha.length-1;i>=0;i--){
		result+=(alpha.charCodeAt(i)-65)*Math.pow(26, i-alpha.length+1);
	}
	return result;
};

function a2c(a){
    var i, c = 0;
    for (i=0; i<a.length; i++){
        c += Math.pow(26, a.length-i-1) * (a.charCodeAt(i) - 65);
    }
    if (a.length > 1) c += Math.pow(26, a.length - 1);
    return c + 1;
}

function c2a(c){
    var q, r, a = '';

    c -= 1;
    if (c < 26) return String.fromCharCode(c + 65) + a;

    while (true){
        q = Math.floor(c / 26);
        r = c % 26;
        if (q == 0) {
            a = String.fromCharCode(r + 64) + a;
            break;
        }
        a = String.fromCharCode(r + 65) + a;
        c = q;
    }
    return a;
}

function convert(s){
    var i, temp;
    s = s.toUpperCase();

    if (/^[A-Z]{1,5}[1-9][0-9]*$/.test(s)) {
        for (i=0; i<s.length; i++){
            if (s.substr(i,1) < 'A'){
                break;
            }
        }
        return "R" + s.substr(i) + "C" + a2c(s.substr(0,i));
    }

    if (/^R[1-9][0-9]*C[1-9][0-9]*$/.test(s)) {
        temp = s.split("C");
        return c2a(temp[1]) + temp[0].substr(1);
    }

    return "Invalid format";
}

var n = readline();
for (var i=0; i<n; i++){
    print(convert(readline()));
}

var a, b;
readline();

while(a = readline())print((b=a.match(/R(\d+)C(\d+)/))?M(b[2]-1)+b[1]:(b=a.match(/^([A-Z]+)(\d+)$/),'R'+b[2]+'C'+N(b[1])));

function N(l){
  var n=l.length-1,i=v=0,c;
	for(;c=l.charCodeAt(i)-64;i++)v=v+Math.pow(26,n-i)*c;
	return v;
}

function M(l){
  var a='';
  for(;l>26;l = parseInt(l / 26))a=String.fromCharCode(l%26+65)+a;
	return String.fromCharCode(+l+64)+a;
}

var data = readline().split(" ");
var n = data[0];
var int = n.replace(/[^0-9]/g, " ").trim().split(" ");

function getNumToCol(num){
    var dividend = num;
    var columnName = "";
    var modulo;

    while (dividend > 0)
    {
        modulo = (dividend - 1) % 26;
        columnName = String.fromCharCode(65 + modulo).toString() + columnName;
        dividend = parseInt((dividend - modulo) / 26);
    }
    return  columnName;
}

function getColToNum(col) {
    var len = col.length;
    var number = 0;

    for (var i = 0, l = len; i < l; i++) {
        var mod = col[l - (i+1)].charCodeAt() - 64;
        var number = number + (Math.pow(26, i) * mod);
    }

    return Strung(number);
}

// RXCY
if (n[0] == "R" && int.length == 2) {
    print(getNumToCol(int[1]) + String(int[0]));
}
// Nomal
else if (/[A-Z]/.test(n[0]) && int.length == 1) {
    print("R" + int[0] + "C" + getColToNum(n[0].replace(/[0-9]/g, " ").split(" ")[0]));
}

// 1B   Электронные таблицы

var n = parseInt(readline());
//var input_line = readline().split(' ').map(Number);
//var n =  input_line[0];
//var m =  input_line[1];

var arr = [];
var out ='';
var reg = /^[R][\d]+[C][\d]+/;
var x, y;

var abc = '0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ';
arr = abc.split(' ');

var arr_S = [];
for (var i = 0; i < arr.length; i++) {
    arr_S[arr[i]] = i;
};

// expected: 'RZ228', found: 'SA228'

for (var i = 0; i < n; i++) {

    str = readline();

    if (reg.test(str)) {
        for (var j = 1; /\d/.test(str[j]); j++) {};
        x = str.substring(1, j); // номер строки
        y = str.substring(j+1, str.length );
        var pos = parseInt(y); // числовой номер столбца
        var valpor = 26; // значение порядка числа в 26-ричной системе
        var por = 1; // порядок числа в 26-ричной системе

        while (valpor < pos) {
            por ++;
            valpor = valpor * 26;
        }

        for (var j = por; j >=1; j--) {
            for (var k = 2; k <= 27; k++) {
                if (Math.pow(26, j-1) * k > pos) {
                    out += arr[k-1];
                    pos -= Math.pow(26, j-1) * (k - 1);
                    break;
                };
                if (Math.pow(26, j-1) * k === pos) {
                    if (j === 1) {
                        out += arr[k];
                    } else {
                        out += arr[k-1];
                    };
                    pos -= Math.pow(26, j-1) * (k-2);
                    break;
                };
            };
        };

        out += x + "\n";

    } else {
        x = str.match(/\d+/); // номер строки
        y = str.match(/[A-Z]+/);   // буквенный номер столбца
        var len = y[0].length;
        var posN = 0; // числовой номер столбца
        for (var j = len; j > 0; j--) {
            posN += arr_S[y[0].substring(len-j, len-j+1)] * Math.pow(26, j-1);
        };

        out += 'R' + x + 'C' + posN.toString() + "\n";

    }
};

print(out);

function a2c(a){
    return a.charCodeAt(0) - 64;
}

function c2a(c){
    var a = '';
    c = parseInt(c);
    if (c > 26)
        a = String.fromCharCode(Math.ceil(c / 26) + 63);
    return a + String.fromCharCode((c-1) % 26 + 65);
}

function convert(s){
    var i, c, temp, row=0, col=0;
    if (/^[A-Z][1-9][0-9]*$/.test(s))
        return "R" + s.substr(1) + "C" + a2c(s.substr(0,1));
    if (/^[A-Z]{2}[1-9][0-9]*$/.test(s))
        return "R" + s.substr(2) + "C" + (a2c(s.substr(0,1)) * 26 + a2c(s.substr(1,1)));
    if (/^R[1-9][0-9]*C[1-9][0-9]*$/.test(s)) {
        temp = s.split("C");
        return c2a(temp[1]) + temp[0].substr(1);
    }
    return "Invalid format";
}

var n = readline();
for (var i=0; i<n; i++){
    print(convert(readline()));
}

var n = parseInt(readline());

print(n);

var data = readline().split(" ");
var n = data[0];
var int = n.replace(/[^0-9]/g, " ").trim().split(" ");

function getNumToCol(num){
    var dividend = num;
    var columnName = "";
    var modulo;

    while (dividend > 0)
    {
        modulo = (dividend - 1) % 26;
        columnName = String.fromCharCode(65 + modulo).toString() + columnName;
        dividend = parseInt((dividend - modulo) / 26);
    }
    return  columnName;
}

function getColToNum(col) {
    var len = col.length;
    var number = 0;

    for (var i = 0, l = len; i < l; i++) {
        var mod = col[l - (i+1)].charCodeAt() - 64;
        var number = number + (Math.pow(26, i) * mod);
    }

    return Strung(number);
}

// RXCY
if (n[0] == "R" && int.length == 2) {
    print(getNumToCol(int[1]) + String(int[0]));
}
// Nomal
else if (/[A-Z]/.test(n[0]) && int.length == 1) {
    print("R" + int[0] + "C" + getColToNum(n[0].replace(/[0-9]/g, " ").split(" ")[0]));
}
else {
    print("");
}

// 1B   Электронные таблицы

var n = parseInt(readline());
//var input_line = readline().split(' ').map(Number);
//var n =  input_line[0];
//var m =  input_line[1];

var arr = [];
var out ='';
var reg = /^[R][\d]+[C][\d]+/;
var x, y;

var abc = '0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ';
arr = abc.split(' ');

var arr_S = [];
for (var i = 0; i < arr.length; i++) {
    arr_S[arr[i]] = i;
};

// expected: 'RZ228', found: 'SA228'

for (var i = 0; i < n; i++) {

    str = readline();

    if (reg.test(str)) {
        for (var j = 1; /\d/.test(str[j]); j++) {};
        x = str.substring(1, j); // номер строки
        y = str.substring(j+1, str.length );
        var pos = parseInt(y); // числовой номер столбца
        var valpor = 26; // значение порядка числа в 26-ричной системе
        var por = 1; // порядок числа в 26-ричной системе

        while (valpor < pos) {
            por ++;
            valpor = valpor * 26;
        }

        for (var j = por; j >=1; j--) {
            for (var k = 2; k <= 26; k++) {
                if (Math.pow(26, j-1) * k > pos) {
                    out += arr[k-1];
                    pos -= Math.pow(26, j-1) * (k - 1);
                    break;
                };
                if (Math.pow(26, j-1) * k === pos) {
                    if (j === 1) {
                        out += arr[k];
                    } else {
                        out += arr[k-1];
                    };
                    pos -= Math.pow(26, j-1) * (k-1);
                    break;
                };
            };
        };

        out += x + "\n";

    } else {
        x = str.match(/\d+/); // номер строки
        y = str.match(/[A-Z]+/);   // буквенный номер столбца
        var len = y[0].length;
        var posN = 0; // числовой номер столбца
        for (var j = len; j > 0; j--) {
            posN += arr_S[y[0].substring(len-j, len-j+1)] * Math.pow(26, j-1);
        };

        out += 'R' + x + 'C' + posN.toString() + "\n";

    }
};

print(out);

var a,b;
readline();

while(a=readline())print((b=a.match(/R(\d+)C(\d+)/))?M(b[2])+b[1]:(b=a.match(/^([A-Z]+)(\d+)$/),'R'+b[2]+'C'+N(b[1])));

function N(l){
  var n=l.length-1,i=v=0,c;
	for(;c=l.charCodeAt(i)-64;i++)v=v+Math.pow(26,n-i)*c;
	return v;
}

function M(l){
  var a='',b=String.fromCharCode;
  for(l--;l>26;l=parseInt(l/26))a=b(l%26+64)+a;
	return b(+l+64)+a;
}

var data = readline().split(" ");
var n = data[0];
var int = n.replace(/[^0-9]/g, " ").trim().split(" ");

function getNumToCol(num){
    var dividend = num;
    var columnName = "";
    var modulo;

    while (dividend > 0)
    {
        modulo = (dividend - 1) % 26;
        columnName = String.fromCharCode(65 + modulo).toString() + columnName;
        dividend = parseInt((dividend - modulo) / 26);
    }
    return  columnName;
}

function getColToNum(col) {
    var len = col.length;
    var number = 0;

    for (var i = 0, l = len; i < l; i++) {
        var mod = col[l - (i+1)].charCodeAt() - 64;
        var number = number + (Math.pow(26, i) * mod);
    }

    return Strung(number);
}

// RXCY
if (n[0] == "R" && int.length == 2) {
    print(getNumToCol(int[1]) + String(int[0]));
}
// Nomal
else if (/[A-Z]/.test(n[0]) && int.length == 1) {
    print("R" + int[0] + "C" + getColToNum(n[0].replace(/[0-9]/g, " ").split(" ")[0]));
}
else {
    print(readline());
}

const n = readline();

const lines = [];
for(var i=0;i<n;i++) {
    lines.push(readline());
}

const CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

function numToCol(num) {
    var n = num;
    var result = "";
    do {
        result = CHARS[ (n-1) % 26 ] + result;
        n = Math.floor( (n-1) / 26 );
    } while(n > 0);
    return result;
}

function colToNum(col) {
    var num = 0;
    for(var i=col.length - 1;i > -1;i--) {
        const chr = col[i];
        const n = Math.pow(26, col.length - i - 1) * (CHARS.indexOf(chr) + 1);
        num += n;
    }
    return num;
}

function trans(coord) {
    if(/^[A-Z]+\d+$/.test(coord)) {
        var col = coord.match(/[A-Z]+/)[0];
        var row = coord.match(/\d+/)[0];
        return  'R' + row + 'C' + colToNum(col);
    } else {
        var row = coord.match(/\d+/)[0];
        var col = coord.match(/\d+$/)[0];
        return  numToCol(col) + row;
    }
}

do {
    const line = lines.shift();
    print(line);
} while(lines.length > 0);

var n = readline();
var str;
var sub1,sub2;
var alf = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

var res;

for (var i = 0; i < n; i++){
    str = readline();
    var re1 = /[R]\d+[C]\d+/g;
    var re2 = /\d+/g;
    var re4 = /\d+/;
    var re3 = /[A-Z]+/g;
    res = re1.exec(str);

    if (res != null){
        sub1 = re2.exec(str);
        sub2 = re2.exec(str);
        if (sub2 > 26) sub2--;
        res = "";
        while(sub2/26>1){
            res = alf[sub2%26]+res;
            sub2 = Math.floor(sub2/26);
        }
        res = alf[--sub2]+res;
        print(res+sub1);
    }
    else {
        sub = re3.exec(str);
        res = 0;
        sub = sub + "";
        var l = sub.length;
        for (var j = 0; j < l; j++){
            res += (alf.indexOf(sub[j])+1) * Math.pow(26,l-j-1)
        }
        sub = re4.exec(str);
        print("R" + sub + "C" + res);
    }
}

//V8 3.31.1

var table = ['Z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
//var n = readline();
var n = 1;

while(n--) {
    //var s = readline();
    var s = "R228C494";
    var e = /R(\d+)C(\d+)/.exec(s);

    if(e) {
        print(getString(e[2]) + e[1]);
    }
    else {
        e = /([A-Z]+)(\d+)/.exec(s);
        print('R' + e[2] + 'C' + getNum(e[1]));
    }
}

function getNum(e) {
    var len = e.length;
    //print(len);
    var total = 0;
    var temp = len;
    for(var i = 0;i < len; i++) {
        for(var j = 1;j <= table.length; j++) {
            if(e[i] == table[j]) {
                //print(j)
                //print(table[j])
                total += j * Math.pow(26, temp - 1);
                //print(total);
                temp--;
            }
        }
    }
    return total;
}

function getString(e) {
    //print(e);
    var answer = '';
    while(e / 26 > 0) {
        answer += table[e % 26];
        //print(e % 26);
        //print(answer);
        if(e % 26 != 0) {
            e = parseInt(e / 26);
        }
        else {
            e = parseInt(e / 26) - 1;
        }
        //print(e);
        //print(table[e % 26]);
    }
    if(e != 0) {
        answer += table[e];
    }
    //print(answer);
    return answer.split("").reverse().join("");
}

// 1B   Электронные таблицы

var n = parseInt(readline());
//var input_line = readline().split(' ').map(Number);
//var n =  input_line[0];
//var m =  input_line[1];

var arr = [];
var out ='';
var reg = /^[R][\d]+[C][\d]+/;
var x, y;

var abc = '0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z';
arr = abc.split(' ');

var arr_S = [];
for (var i = 0; i < arr.length; i++) {
    arr_S[arr[i]] = i;
};

for (var i = 0; i < n; i++) {

    str = readline();

    if (reg.test(str)) {
        for (var j = 1; /\d/.test(str[j]); j++) {};
        x = str.substring(1, j); // номер строки
        y = str.substring(j+1, str.length );
        var pos = parseInt(y); // числовой номер столбца
        var valpor = 26; // значение порядка числа в 26-ричной системе
        var por = 1; // порядок числа в 26-ричной системе

        while (valpor < pos) {
            por ++;
            valpor = valpor * 26;
        }

        for (var j = por; j >=1; j--) {
            for (var k = 2; k <= 26; k++) {
                if (Math.pow(26, j-1) * k > pos) {
                    out += arr[k-1];
                    pos -= Math.pow(26, j-1) * (k - 1);
                    break;
                };
            };
        };

        out += x + "\n";

    } else {
        x = str.match(/\d+/); // номер строки
        y = str.match(/[A-Z]+/);   // буквенный номер столбца
        var len = y[0].length;
        var posN = 0; // числовой номер столбца
        for (var j = len; j > 0; j--) {
            posN += arr_S[y[0].substring(len-j, len-j+1)] * Math.pow(26, j-1);
        };

        out += 'R' + x + 'C' + posN.toString() + "\n";

    }
};

print(out);

// 1B   Электронные таблицы
/*
function main_1(){
    var n = parseInt(readline());
    var ans = 0;
    while (n--) {
        var nums = readline().split(' ').map(Number);
        ans += (nums[2] - nums[0] + 1) * (nums[3] - nums[1] + 1);
    }
    print(ans);
}

function main(){
    var line  = readline();
    //var line = prompt();
    var n = line.length;
    //alert(line);
    var m = 0;
    for(i=0;i<n;i+=2){
        for(j=i+1;j<n;j+=2){
            var ex = [line.slice(0, i), '(', line.slice(i,j) , ')' , line.slice(j)].join('');
            m = Math.max(m,eval(ex));
        }
    }
    print(m);
}
*/

var n = parseInt(readline());
//var input_line = readline().split(' ').map(Number);
//var n =  input_line[0];
//var m =  input_line[1];

var arr = [];
var out ='';
var reg = /^[R][\d]+[C][\d]+/;
var x, y;

var abc = '0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z';
arr = abc.split(' ');

var arr_S = [];
for (var i = 0; i < arr.length; i++) {
    arr_S[arr[i]] = i;
};
// RAA23R23C78
// AAA23

//R23C78

for (var i = 0; i < n; i++) {

    str = readline();

    if (reg.test(str)) {
        for (var j = 1; /\d/.test(str[j]); j++) {};
        x = str.substring(1, j); // номер строки
        y = str.substring(j+1, str.length );
        var pos = parseInt(y); // числовой номер столбца
        var valpor = 26; // значение порядка числа в 26-ричной системе
        var por = 1; // порядок числа в 26-ричной системе

        while (valpor < pos) {
            por ++;
            valpor = valpor * 26;
        }

        for (var j = por; j >=1; j--) {
            for (var k = 2; k <= 26; k++) {
                if (Math.pow(26, j-1) * k >= pos) {
                    out += arr[k-1];
                    pos -= Math.pow(26, j-1) * (k - 1);
                    break;
                };
            };
        };

        out += x + "\n";

    } else {
        x = str.match(/\d+/); // номер строки
        y = str.match(/[A-Z]+/);   // буквенный номер столбца
        var len = y.length;
        var posN = 0; // числовой номер столбца
        for (var j = len; j > 0; j--) {
            posN += arr_S[str[j]] * Math.pow(26, j);
        };

        out += 'R' + x + 'C' + posN.toString() + "\n";

    }
};

print(out);

var tests = readline().split('\n').slice(1);
var LETTERS = [
  'Z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
  'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y'
];

for (var i = 1; i < tests.length; i++) {
  print(calc(tests[i]));
}

function calc(str) {
  return isRC(str) && calcRC(str) || calcNRC(str);
}

function calcRC(str) {
  var res = [];
  var num = parseInt(str.slice(str.indexOf('C') + 1));
  var rest = 0;
  while (num) {
    rest = num % 26;
    res.push(LETTERS[rest]);
    if (rest === 0 && num === 26) break;
    num = Math.floor(num / 26);
  }

  return res.reverse().join('') + str.slice(1, str.indexOf('C'));
}

function calcNRC(str) {
  var letters = str.slice(0, str.search(/\d/));
  var sum = 0;
  for (var i = letters.length - 1, p = 0; i >= 0; i--, p++) {
    var index = LETTERS.indexOf(letters[i]);
    sum += (index && index || 26) * Math.pow(26, p);
  }
  return 'R' + str.slice(letters.length) + 'C' + sum;
}

function isRC(str) {
  return /^R\d*C\d*$/.test(str);
}

var a,b;
readline();

while (a=readline())print((b=a.match(/R(\d+)C(\d+)/))?M(b[2])+b[1]:(b=a.match(/^([A-Z]+)(\d+)$/),'R'+b[2]+'C'+N(b[1])));

function N(l){
  var n=l.length-1,i=v=0,c;
	for(;c=l.charCodeAt(i)-64;i++) v=v+Math.pow(26,n-i)*c;
	return v;
}

function M(l){
  var a='',b=String.fromCharCode;
  for(;l>26;l=parseInt(l/26))a=b(l%26+64)+a;
	return b(l+64)+a;
}

// 1B   Электронные таблицы
/*
function main_1(){
    var n = parseInt(readline());
    var ans = 0;
    while (n--) {
        var nums = readline().split(' ').map(Number);
        ans += (nums[2] - nums[0] + 1) * (nums[3] - nums[1] + 1);
    }
    print(ans);
}

function main(){
    var line  = readline();
    //var line = prompt();
    var n = line.length;
    //alert(line);
    var m = 0;
    for(i=0;i<n;i+=2){
        for(j=i+1;j<n;j+=2){
            var ex = [line.slice(0, i), '(', line.slice(i,j) , ')' , line.slice(j)].join('');
            m = Math.max(m,eval(ex));
        }
    }
    print(m);
}
*/

var n = parseInt(readline());
//var input_line = readline().split(' ').map(Number);
//var n =  input_line[0];
//var m =  input_line[1];

var arr = [];
var out ='';
var reg = /^[R][\d]+[C][\d]+/;
var x, y;

var abc = '0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z';
arr = abc.split(' ');

var arr_S = [];
for (var i = 0; i < arr.length; i++) {
    arr_S[arr[i]] = i;
};
// RAA23R23C78
// AAA23

//R23C78

for (var i = 0; i < n; i++) {

    str = readline();

    if (reg.test(str)) {
        for (var j = 1; /\d/.test(str[j]); j++) {};
        x = str.substring(1, j); // номер строки
        y = str.substring(j+1, str.length );
        var pos = parseInt(y); // числовой номер столбца
        var valpor = 26; // значение порядка числа в 26-ричной системе
        var por = 1; // порядок числа в 26-ричной системе

        while (valpor < pos) {
            por ++;
            valpor = valpor * 26;
        }

        for (var j = por; j >=1; j--) {
            for (var k = 2; k <= 26; k++) {
                if (Math.pow(26, j) * k >= pos) {
                    out += arr[k-1];
                    pos -= Math.pow(26, j) * (k - 1);
                    break;
                };
            };
        };

        out += x + "\n";

    } else {
        x = str.match(/\d+/); // номер строки
        y = str.match(/[A-Z]+/);   // буквенный номер столбца
        var len = y.length;
        var posN = 0; // числовой номер столбца
        for (var j = len; j > 0; j--) {
            posN += arr_S[str[j]] * Math.pow(26, j);
        };

        out += 'R' + x + 'C' + posN.toString() + "\n";

    }
};

print(out);

const readline = require('readline');
const rl = readline.createInterface({
	input: process.stdin,
	output: process.stdout,
	terminal: false
});

const abcChars = '_ABCDEFGHIGKLMNOPQRSTUVWXYZ';
const dec2abc = dec => {
	let d = dec;
	let res = '';

	while (d > 0) {
		const mod = d % 26;
		res = abcChars[mod === 0 ? 26 : mod] + res;
		d = Math.floor(d / 26) - (mod === 0 ? 1 : 0);
	}

	return res;
};
const abc2dec = abc => {
	let res = 0;

	for (let i = 0; i < abc.length; i++) {
		res += abcChars.indexOf(abc[i]);
		if (i !== abc.length - 1) {
			res *= 26;
		}
	}

	return res;
};

let n, counter = 0;
const res = [];

rl.on('line', function (line) {
	if (!n) {
		n = parseInt(line);
	} else {
		const rc = line.match(/R(\d+)C(\d+)/);
		if (rc) {
			res.push(dec2abc(parseInt(rc[2])) + rc[1]);
		} else {
			const regular = line.match(/([^\d]+)(\d+)/);
			res.push('R' + regular[2] + 'C' + abc2dec(regular[1]));
		}

		counter++;
		if (counter === n) {
			for (let i = 0; i < res.length; i++) {
				console.log(res[i]);
			}
			rl.close();
		}
	}
});

var pos = readline();
var array = [];

for (var i = 0; i < pos; i++) {
    array.push(readline());
}

for (var i = 0; i < array.length; i++) {
    var text = array[i];
    var pattern = /R[(0-9)]{1,100}C[(0-9)]{1,100}/;
    if (pattern.test(text)) {
        var row = 0;
        var col = 0;
        var separator = 0;
        for (var j = 0; j < text.length; j++) {
            if (text[j] == 'C') {
                separator = j;
            }
        }

        var row = parseInt(text.substring(0, separator).replace(/[^0-9]/g, ''));
        var col = parseInt(text.substring(separator, text.length).replace(/[^0-9]/g, ''));
        var text = '';
        while(col > 0) {
            if (col < 26) break;

            var remain = col % 26;
            col = Math.floor(col / 26);

            var char = String.fromCharCode(remain + 64);
            text = char + text;
        }

        var first = String.fromCharCode(col + 64);
        text = first + text;

        var converted = text + row;
        print(converted);
    } else {
        var separator = 0;
        for (var j = 0; j < text.length; j++) {
            var number = parseInt(text[j]);
            if (number >= 0 && number <= 9) {
                separator = j;
                break;
            }
        }

        var row = parseInt(text.substring(separator, text.length));
        var col = text.substring(0, separator);
        var colNum = 0;
        var ascii = 64;
        col = col.split('').reverse();
        for (var j = 0; j < col.length; j++) {
            var char = col[j].toUpperCase().charCodeAt(0) - ascii;
            if (j === 0) {
                colNum += char;
            } else {
                colNum += (26 * j * char);
            }
        }

        var converted = 'R' + row + 'C' + colNum;
        print(converted);
    }
}

function getNumToCol(num){
    var dividend = num;
    var columnName = "";
    var modulo;

    while (dividend > 0)
    {
        modulo = (dividend - 1) % 26;
        columnName = String.fromCharCode(65 + modulo).toString() + columnName;
        dividend = parseInt((dividend - modulo) / 26);
    }
    return  columnName;
}

function getColToNum(col) {
    var len = col.length;
    var number = 0;

    for (var i = 0, l = len; i < l; i++) {
        var mod = col[l - (i+1)].charCodeAt() - 64;
        var number = number + (Math.pow(26, i) * mod);
    }

    return String(number);
}

for (var i = 0, l = readline().split(" "); i < l; i++) {
    var n = String(readline().split(" "));
    var int = n.replace(/[^0-9]/g, " ").trim().split(" ");

    // RXCY
    if (n[0] == "R" && int.length == 2) {
        print(getNumToCol(int[1]) + String(int[0]));
    }
    // Nomal
    else if (/[A-Z]/.test(n[0]) && int.length == 1) {
        print("R" + int[0] + "C" + getColToNum(n[0].replace(/[0-9]/g, " ").split(" ")[0]));
    }
}

var pos = readline();
var array = [];

for (var i = 0; i < pos; i++) {
    array.push(readline());
}

for (var i = 0; i < array.length; i++) {
    var text = array[i];
    var pattern = /R[(0-9)]{1,10}C[(0-9)]{1,10}/;
    if (pattern.test(text)) {
        var row = 0;
        var col = 0;
        var separator = 0;
        for (var j = 0; j < text.length; j++) {
            if (text[j] == 'C') {
                separator = j;
            }
        }

        var row = parseInt(text.substring(0, separator).replace(/[^0-9]/g, ''));
        var col = parseInt(text.substring(separator, text.length).replace(/[^0-9]/g, ''));
        var text = '';
        while(col > 0) {
            if (col < 26) break;

            var remain = col % 26;
            col = Math.floor(col / 26);

            var char = String.fromCharCode(remain + 64);
            text = char + text;
        }

        var first = String.fromCharCode(col + 64);
        text = first + text;

        var converted = text + row;
        print(converted);
    } else {
        var separator = 0;
        for (var j = 0; j < text.length; j++) {
            var number = parseInt(text[j]);
            if (number >= 0 && number <= 9) {
                separator = j;
                break;
            }
        }

        var row = parseInt(text.substring(separator, text.length));
        var col = text.substring(0, separator);
        var colNum = 0;
        var ascii = 64;
        col = col.split('').reverse();
        for (var j = 0; j < col.length; j++) {
            var char = col[j].toUpperCase().charCodeAt(0) - ascii;
            if (j === 0) {
                colNum += char;
            } else {
                colNum += (26 * j * char);
            }
        }

        var converted = 'R' + row + 'C' + colNum;
        print(converted);
    }
}