Spreadsheet Locations


Submit solution

Points: 1
Time limit: 2.0s
Memory limit: 512M

Author:
Problem type

In popular spreadsheet applications (such as Apple's Numbers) cells are identified in one of two systems.

In the first system, the first 26 columns are denoted as 'A' to 'Z', column 27 is denoted as 'AA', 28 as 'AB' etc. Rows are marked with integers beginning from 1. The cell name is the concatenation of column and row specifiers. E.g. A1 is column 1, row 1, AC24 is column 29, row 24.

In the second system, rows are specified first as RX and columns are specified as CY, where X and Y are positive integers. R24C29 is the same cell as the previous example.

You need to write a program that reads a sequence of cell coordinates and translates them to the opposite system.

Input Specification

The first line contains \(n(1\leq n \leq 10^5)\), the number of test cases.

The following \(n\) lines contain a single cell coordinate in either system specified. All coordinates are guaranteed to be correct and no row/column number will be greater than \(10^6\). Further all letter specifications will be strings containing capital letters from A - Z.

Output Specification

\(n\) lines, each containing the alternative cell coordinate for the corresponding test case.

Sample Input 1

2
A1
AC24

Sample Output 1

R1C1
R24C29

Sample Input 2

2
R123C72
RA3

Sample Output 2

BT123
R3C469

Comments

There are no comments at the moment.