codeparrot/codecomplex huggingface dataset:
// Problem: 1_B. Spreadsheets
// Time complexity: linear

import java.util.Scanner;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author madis
 */
public class Spreadsheet {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        in.nextLine();
        for (int i = 0; i < N; i++) {
            String str = in.nextLine();
            if (str.indexOf("R") == 0 && str.indexOf("R") + 1 < str.indexOf("C") && isNum(str.charAt(1))) {
                int row = Integer.parseInt(str.substring(str.indexOf("R") + 1, str.indexOf("C")));
                int col = Integer.parseInt(str.substring(str.indexOf("C") + 1));
                System.out.println(convertRC(row, col));
            } else {
                String row = "";
                int j = 0;
                while (str.charAt(j) >= 'A' && str.charAt(j) <= 'Z') {
                    row += str.charAt(j);
                    j++;
                }
                int num = Integer.parseInt(str.substring(j));
                System.out.println(convertAB(row, num));
            }
        }
    }

    static String convertAB(String str, int num) {
        String result = "";
        int col = 0;
        for (int i = 0; i < str.length(); i++) {
            col += (int)Math.pow(26, (str.length()) - (i + 1)) * (str.charAt(i) - 'A' + 1);
        }
        result += "R" + num;
        result += "C" + col;

        return result;
    }

    static String convertRC(int row, int column) {
        String result = "";
        while (column > 0) {
            int index = column % 26;

            char c;
            if (index == 0) {
                c = 'Z';
                column = column - 26;
            } else {
                c = (char) ('A' + index - 1);
                column = column - index;
            }
            result += c;

            column = column / 26;
        }

        String res = "";
        for (int i = 0; i < result.length(); i++) {
            res += result.charAt(result.length() - (i + 1));
        }
        res += row;
        return res;
    }

    static boolean isNum(char x){
        return x>'0'&&x<='9';
    }
}
// Problem: 1_B. Spreadsheets
// Time complexity: linear
import static java.lang.Math.*;
import static java.lang.System.currentTimeMillis;
import static java.lang.System.exit;
import static java.lang.System.arraycopy;
import static java.util.Arrays.sort;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.fill;
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		try {
			if (new File("input.txt").exists())
				System.setIn(new FileInputStream("input.txt"));
		} catch (SecurityException e) {
		}
		new Thread() {
			public void run() {
				try {
					new Main().run();
				} catch (IOException e) {
				}
			}
		}.start();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");

	int MAXDEG = 5;

	private void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		int n = nextInt();
		int[] sumDegs = new int[MAXDEG + 1];
		sumDegs[0] = 1;
		int deg = 1;
		for (int i = 1; i <= MAXDEG; i++) {
			deg *= 26;
			sumDegs[i] = sumDegs[i - 1] + deg;
		}
		for (int i = 0; i < n; i++) {
			String s = nextLine();
			String pref = "";
			int endPos = -1;
			for (int j = 0; j < s.length(); j++) {
				if (!isLet(s.charAt(j))) {
					endPos = j;
					break;
				}
				pref += s.charAt(j);
			}
			int num = -1;
			try {
				num = Integer.parseInt(s.substring(endPos));
			} catch (Exception e) {
			}
			if (num != -1) {
				int col = sumDegs[pref.length() - 1];
				int val = 0;
				for (int j = 0; j < pref.length(); j++) {
					val = val * 26 + (pref.charAt(j) - 'A');
				}
				col += val;
				out.println("R" + num + "C" + col);
			} else {
				int row = Integer.parseInt(s.substring(1, s.indexOf('C')));
				int col = Integer.parseInt(s.substring(s.indexOf('C') + 1));
				int len = MAXDEG;
				while (col < sumDegs[len])
					len--;
				len++;
				col -= sumDegs[len - 1];
				String res = "";
				while (col > 0) {
					res = (char) (col % 26 + 'A') + res;
					col /= 26;
				}
				while (res.length() < len)
					res = "A" + res;
				out.println(res + row);
			}
		}
		in.close();
		out.close();
	}

	private boolean isLet(char c) {
		return c >= 'A' && c <= 'Z';
	}

	void chk(boolean b) {
		if (b)
			return;
		System.out.println(new Error().getStackTrace()[1]);
		exit(999);
	}
	void deb(String fmt, Object... args) {
		System.out.printf(Locale.US, fmt + "%n", args);
	}
	String nextToken() throws IOException {
		while (!st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}
	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}
	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}
	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			st = new StringTokenizer(s);
		}
		return false;
	}
}
// Problem: 1_B. Spreadsheets
// Time complexity: linear
import java.util.Scanner;
import java.io.PrintWriter;

/**
 * @author Egor Kulikov (kulikov@devexperts.com)
 */
public class Spreadsheets implements Runnable {
	private Scanner in = new Scanner(System.in);
	private PrintWriter out = new PrintWriter(System.out);
	private String s, ans;

	public static void main(String[] args) {
		new Thread(new Spreadsheets()).start();
	}

	private void read() {
		s = in.next();
	}

	private void solve() {
		if (s.matches("R\\d+C\\d+")) {
			s = s.replace('R', ' ').replace('C', ' ');
			Scanner ss = new Scanner(s);
			int r = ss.nextInt();
			int c = ss.nextInt();
			c--;
			StringBuffer b = new StringBuffer();
			int c26 = 26;
			int cc = 0;
			while (cc + c26 <= c) {
				cc += c26;
				c26 *= 26;
			}
			c -= cc;
			while (c26 > 1) {
				c26 /= 26;
				b.append((char) (c / c26 + 'A'));
				c %= c26;
			}
			ans = b.toString() + r;
		} else {
			int p = 0;
			while (!Character.isDigit(s.charAt(p))) {
				p++;
			}
			int c26 = 1;
			int cc = 0;
			for (int i = 0; i < p; i++) {
				cc += c26;
				c26 *= 26;
			}
			for (int i = 0; i < p; i++) {
				c26 /= 26;
				cc += c26 * (s.charAt(i) - 'A');
			}
			ans = "R" + s.substring(p) + "C" + cc;
		}
	}

	private void write() {
		out.println(ans);
	}

	public void run() {
		int n = in.nextInt();
		for (int i = 0; i < n; i++) {
			read();
			solve();
			write();
		}
		out.close();
	}
}
// Problem: 1_B. Spreadsheets
// Time complexity: linear
import java.io.*;
import java.util.*;

public class Main {
//	static Scanner in;
	static PrintWriter out;
	static BufferedReader in;

	public static void main(String[] args) throws Exception {
//		in = new Scanner(System.in);
		out = new PrintWriter(System.out);
		in = new BufferedReader(new InputStreamReader(System.in));
		
		int n = new Integer(in.readLine());

		for (int i = 0; i < n; i++) {
			String s = in.readLine();
			int x = 0;
			while (s.charAt(x) - 'A' >= 0 && s.charAt(x) - 'Z' <= 0) x++;
			int y = s.length() - 1;
			while (s.charAt(y) - '0' >= 0 && s.charAt(y) - '9' <= 0) y--;

			if (x > y) {
				int k = 1;
				int a = 1;
				for (int j = 1; j < x; j++) {
					k *= 26;
					a += k;
				}
				for (int j = 0; j < x; j++) {
					a += k*(s.charAt(j) - 'A');
					k /= 26;
				}
				int b = Integer.parseInt(s.substring(x));
				out.println("R" + b + "C" + a);
			} else {
				while (s.charAt(x) - '0' >= 0 && s.charAt(x) - '9' <= 0) x++;
				int b = Integer.parseInt(s.substring(1, x));
				int a = Integer.parseInt(s.substring(x + 1));
				int num = 0;
				int k = 1;
				while (a >= k) {
					a -= k;
					k *= 26;
				}
				k /= 26;
				while (k > 0) {	
					out.print((char)('A' + (a/k)));
					a %= k;
					k /= 26;
				}
				out.println(b);
			}
		}
		out.close();
	}
}
// Problem: 1_B. Spreadsheets
// Time complexity: linear


import java.util.*;
import java.math.*;
import static java.lang.Math.*;
import static java.math.BigInteger.*;
import static java.lang.Character.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class B {
	static final int[] num = new int[7];
	static {
		for(int i = 1, c = 1; i <= 6; i++, c *= 26)
			num[i] = num[i-1] + c;
	}
	public void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		while(n-- > 0) {
			String s = sc.next();
			System.out.println(s.matches("R[0-9]+C[0-9]+") ? toABdd(s) : toRC(s));
		}
	}

	String toRC(String s) {
		String ss = s.split("[0-9]+")[0];
		String sn = s.split("[A-Z]+")[1];
		int r = 0;
		for(char c : ss.toCharArray())
			r = r * 26 + c - 'A';
		r += num[ss.length()];
		int c = Integer.parseInt(sn);
		return "R" + c + "C" + r;
	}

	String toABdd(String s) {
		String[] ss = s.split("[RC]");
		int c = Integer.parseInt(ss[1]);
		int r = Integer.parseInt(ss[2]);
		int a = 0;
		while(r > num[++a]);
		a--;
		r -= num[a];
		char[] cs = new char[a];
		for(int i = 0; i < a; i++, r /= 26)
			cs[a-i-1] = (char) (r % 26 + 'A');
		return new String(cs) + c;
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String...args) {
		new B().run();
	}
}
// Problem: 1_B. Spreadsheets
// Time complexity: linear
import java.io.*;
import java.util.*;

/**
 * @author def
 * @version 1.0
 */
public class B {

    public static void main(String[] args) throws IOException {
        new B().solve();
    }

    void solve() throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);

        int n = Integer.parseInt(in.readLine());
        while (n-- > 0) {
            String s = in.readLine();
            int pr = s.indexOf('R');
            int pc = s.indexOf('C');
            if (pr == 0 && pc > 1 && Character.isDigit(s.charAt(1))) {
                int r = Integer.parseInt(s.substring(1, pc));
                int c = Integer.parseInt(s.substring(pc + 1, s.length()));
                out.println(i2s(c) + r);
            } else {
                int i = 0;
                while (!Character.isDigit(s.charAt(i))) ++i;
                out.println("R" + Integer.parseInt(s.substring(i, s.length())) + "C" + s2i(s.substring(0, i)));
            }
        }

        out.close();
    }

    int s2i(String s) {
        int r = 0;
        for (int i = 0; i < s.length(); ++i) {
            r = r * 26 + (s.charAt(i) - 'A' + 1);
        }
        return r;
    }

    String i2s(int i) {
        StringBuffer s = new StringBuffer();
        while (i > 0) {
            i -= 1;
            s.append((char)('A' + (i % 26)));
            i /= 26;
        }
        return s.reverse().toString();
    }

    BufferedReader in;
    PrintWriter out;
}
// Problem: 1_B. Spreadsheets
// Time complexity: linear
import java.util.*;
import java.math.*;
import java.io.*;

public class B implements Runnable {
	public static void main(String[] args) {
		new Thread(new B()).start();
	}

	StringTokenizer st;
	PrintWriter out;
	BufferedReader br;
	boolean eof = false, in_out = false, std = false;

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return "0";
			}
		}
		return st.nextToken();
	}

	String nextLine() {
		String ret = "";
		try {
			ret = br.readLine();
		} catch (Exception e) {
			ret = "";
		}
		if (ret == null) {
			eof = true;
			return "$";
		}
		return ret;
	}

	String nextString() {
		return nextToken();
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}

	BigInteger nextBigInteger() {
		return new BigInteger(nextToken());
	}

	public void run() {
		// long time = System.currentTimeMillis();
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(111);
		}
		// System.err.println(System.currentTimeMillis() - time);
	}

	void solve() {
		int n = nextInt();
		for (int i = 0; i < n; i++) {
			solve2();
		}
	}

	void solve2() {
		String s = nextToken();
		boolean wasNum = false, isFirst = false;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) >= '0' && s.charAt(i) <= '9') {
				wasNum = true;
			} else if (wasNum) {
				isFirst = true;
				break;
			}
		}
		if (isFirst) {
			StringTokenizer e = new StringTokenizer(s, "RC");
			int y = Integer.parseInt(e.nextToken());
			int x = Integer.parseInt(e.nextToken()) - 1;
			go1(x, y);
		} else {
			go2(s);
		}
	}

	void go1(int x, int y) {
		long cur = 26;
		int len = 1;
		while (x >= cur) {
			x -= cur;
			cur *= 26;
			len++;
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < len; i++) {
			sb.append((char) ('A' + x % 26));
			x /= 26;
		}
		out.println(sb.reverse().toString() + y);
	}

	void go2(String s) {
		int id = -1;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) <= '9' && s.charAt(i) >= '0') {
				id = i;
				break;
			}
		}
		String s1 = s.substring(0, id);
		String s2 = s.substring(id);
		int x = 0;
		int cur = 26;
		for (int i = 1; i < s1.length(); i++) {
			x += cur;
			cur *= 26;
		}
		int d = 0;
		for (int i = 0; i < s1.length(); i++) {
			d *= 26;
			d += s1.charAt(i) - 'A';
		}
		x += d;
		out.println("R" + s2 + "C" + (x + 1));
	}
}
// Problem: 1_B. Spreadsheets
// Time complexity: linear
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.text.NumberFormat;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Locale;
import java.util.Queue;
import java.util.Random;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Solution implements Runnable {
	
	public static void main(String[] args) {
		(new Thread(new Solution())).start();
	}
	
	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;
	
	String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}
	
	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
	
	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
	
	String sti(String s) {
		int res = 0;
		int q = 1;
		int qq = 0;
		for (int i = 0; i < s.length(); i++) {
			if (i > 0) qq += q;
			res = res * 26 + s.charAt(i) - 'A';
			q *= 26;
		}
		return Integer.toString(qq + res + 1);
	}
	
	String its(String s) {
		int q = Integer.parseInt(s);
		String res = "";
		int w = 26;
		int l = 1;
		while (q > w) {
			q -= w;
			l++;
			w *= 26;
		}
		q--;
		if (q == 0) return "A";
		while (q > 0) {
			res = "" + (char)('A' + q % 26) + res;
			l--;
			q /= 26;
		}
		for (; l > 0; l--) res = "A" + res;
		return res;
	}
	        
	void solve() throws IOException {
		int n = nextInt();
		for (int i = 0; i < n; i++) {
			String s = nextToken();
			int j = 0;
			while (!Character.isDigit(s.charAt(j))) j++;
			int q = j + 1;
			while (q < s.length() && Character.isDigit(s.charAt(q))) q++;
			if (q == s.length()) {
				out.println("R" + s.substring(j) + "C" + sti(s.substring(0, j)));
			} else {
				String w = s.substring(j, q);
				while (!Character.isDigit(s.charAt(q))) q++;
				out.println(its(s.substring(q)) + w);
			}
		}
	}
	
	public void run() {
		try {
//			in = new BufferedReader(new FileReader(new File("input.txt")));
//			out = new PrintWriter(new File("output.txt"));
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
		} catch (IOException e) {
			e.printStackTrace();
		}
		out.flush();
	}

}
// Problem: 1_B. Spreadsheets
// Time complexity: linear
import java.io.*;
import java.util.*;

public class Solution {
	
	private BufferedReader in;
	private PrintWriter out;
	private StringTokenizer st;

	void solve() throws IOException {
		String s = next();
		int u = s.indexOf('R');
		int v = s.indexOf('C');
		if (u == 0 && v != -1 && u < v) {
			String a = s.substring(u + 1, v);
			String b = s.substring(v + 1);
			try {
				int aa = Integer.parseInt(a);
				int bb = Integer.parseInt(b) - 1;
				int pow = 26, len = 1;
				while (bb >= pow) {
					bb -= pow;
					pow *= 26;
					++len;
				}
				String r = "";
				for (int i = 0; i < len; ++i) {
					r = ((char)(bb % 26 + 'A')) + r;
					bb /= 26;
				}
				out.println(r + aa);
				return;
			} catch (NumberFormatException e) {
			}
		}
		u = 0;
		while (u < s.length() && Character.isLetter(s.charAt(u))) {
			++u;
		}
		String a = s.substring(0, u);
		String b = s.substring(u);
		out.println("R" + b + "C" + toInt(a));
	}

	private int toInt(String a) {
		int r = 0;
		for (int i = 0; i < a.length(); ++i) {
			r *= 26;
			r += a.charAt(i) - 'A';
		}
		int pow = 1;
		for (int i = 0; i < a.length(); ++i) {
			r += pow;
			pow *= 26;
		}
		return r;
	}

	Solution() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		
		eat("");
		
		int tests = nextInt();
		for (int test = 0; test < tests; ++test) {
			solve();
		}
		
		in.close();
		out.close();
	}
	
	private void eat(String str) {
		st = new StringTokenizer(str);
	}
	
	String next() throws IOException {
		while (!st.hasMoreTokens()) {
			String line = in.readLine();
			if (line == null) {
				return null;
			}
			eat(line);
		}
		return st.nextToken();
	}
	
	int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
	
	long nextLong() throws IOException {
		return Long.parseLong(next());
	}
	
	double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	public static void main(String[] args) throws IOException {
		new Solution();
	}
}
// Problem: 1_B. Spreadsheets
// Time complexity: linear
import java.util.*;
import java.io.*;
public class Main
{
	public static void main(String args[]) throws IOException
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s;
		int i,j;
		for(i=0;i<n;i++)
		{
			s = sc.next();
			j = 0;
			boolean ok;
                        while((s.charAt(j)>='A')&&(s.charAt(j)<='Z')) j++;
                        while((j<s.length())&&(s.charAt(j)>='0')&&(s.charAt(j)<='9')) j++;
                        if (j==s.length()) ok = true; else ok = false;
                        String s1="",s2="";
                        if (ok)
                        {
                        	j = 0;
                        	while((s.charAt(j)>='A')&&(s.charAt(j)<='Z')) 
                        	{
                        		s1 += s.charAt(j);
                        		j++;
                        	}
                        	while(j<s.length()) 
                        	{
                        		s2 += s.charAt(j);
                        		j++;
                        	}
                        	int v = 0,p = 1;
                        	for(j=s1.length()-1;j>=0;j--)
                        	{
                        		v += p*(s1.charAt(j)-'A'+1);
                        		p*=26;
                        	}
                        	System.out.println("R"+s2+"C"+v);
                        } else
                        {
                        	j = 1;
                        	while((s.charAt(j)>='0')&&(s.charAt(j)<='9'))
                        	{
                        		s1 += s.charAt(j);
                        		j++;
                        	}
                        	j++;
                        	while(j<s.length())
                        	{
                        		s2 += s.charAt(j);
                        		j++;
                        	}
				Integer a = new Integer(s2);
                        	String s3="";
                        	int d;
                        	while(a > 0)
                        	{
                        		d = a%26; a/=26;
                        		if (d==0) {d=26; a--;} 
                        		s3 = Character.toUpperCase(Character.forDigit(9+d,36)) + s3;          
                        	}
                        	System.out.println(s3+s1);
                        }
		}
	}
}
// Problem: 1_B. Spreadsheets
// Time complexity: linear
import java.util.Scanner;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author madi
 */
public class Speadsheets {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = Integer.parseInt(sc.nextLine());
        String code = "";
        

    for (int i = 0; i < n; i++) {
        long chResult = 0;
        long chResult1 = 0;
        long nResult = 0;
        long nResult1 = 0;
        boolean t = false;
        boolean k = false;
        code = sc.nextLine();

        for (int j = 0; j < code.length(); j++) {
            char c = code.charAt(j);
            if (('Z' - c) < 33) {
                if (t) {
                    chResult1 = chResult;
                    chResult = 0;
                    t = false;
                    k = true;
                }
                chResult = chResult * 26 + (26 - ('Z' - c));
            } else {
                t = true;
                if (k) {
                    nResult1 = nResult;
                    nResult = 0;
                    k = false;
                }
                nResult = nResult * 10 + (9 - ('9' - c));
            }

        }

        if (chResult1 == 0) {
            System.out.println("R" + nResult + "C" + chResult);
        } else {
            System.out.println(convert(nResult) + nResult1);
        }

    }

    }

    private static String convert(long number) {
        String [] chars = new String[]{"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"};
        String result = "";
        int rem = 0;
        int m = 0;
        while (number > 0) {
        	m = 0;
            rem = (int) (number % 26);
            result = chars[rem] + result;
            /*if (number == 26) {
            	number = -1;
            }*/
            if (number % 26 == 0) {
            	m = 1;
            }
            number = number / 26;
            number = number - m;
        }
        return result;
    }
}
// Problem: 1_B. Spreadsheets
// Time complexity: linear
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Round1B {

	public static void main(String[] args) throws Exception {
		new Round1B().run();
	}

	private void run() throws Exception {
		Scanner sc = new Scanner(System.in);
		int tc = Integer.parseInt(sc.nextLine().trim());
		while (tc > 0) {
			String s = sc.nextLine().trim();
			if (s.matches("R[0-9]+C[0-9]+")) {
				Pattern p = Pattern.compile("R([0-9]+)C([0-9]+)");
				Matcher m = p.matcher(s);
				if (m.matches()) {
					int rows = Integer.parseInt(m.group(1));
					int cols = Integer.parseInt(m.group(2));
					String col = "";
					while (cols > 0) {
						int mod = (cols - 1) % 26;
						col = (char)('A' + mod) + col;
						cols = (cols - 1) / 26;
					}
					System.out.println(col + rows);
				} else {
					throw new Exception();
				}
			} else {
				Pattern p = Pattern.compile("([A-Z]+)([0-9]+)");
				Matcher m = p.matcher(s);
				if (m.matches()) {					
					int rows = Integer.parseInt(m.group(2));
					int cols = 0;
					int mul = 1;
					for (int i = m.group(1).length() - 1; i >= 0; i--) {
						cols += mul * (m.group(1).charAt(i) - 'A' + 1);
						mul *= 26;
					}
					System.out.printf("R%dC%d\n", rows, cols);
				}
				else {
					throw new Exception();
				}
			} 
			tc--;
		}
		sc.close();
	}

}