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.

package main

import (
	"fmt"
	"math"
	"regexp"
	"strconv"
)

func toPattern1(row int, col int) string {
	return fmt.Sprintf("R%dC%d", row, col)
}

func toPattern2(row int, col int) string {
	colString := ""
	for col > 0 {
		if col%26 == 0 {
			colString = string('Z') + colString
			col = col/26 - 1
		} else {
			colString = string('A'+byte(col%26)-1) + colString
			col = col / 26
		}
	}

	return fmt.Sprintf("%s%d", colString, row)
}

func main() {
	var n int
	fmt.Scanf("%d", &n)

	pattern1, _ := regexp.Compile("R([0-9]+)C([0-9]+)")
	pattern2, _ := regexp.Compile("([A-Z]+)([0-9]+)")
	var row, col int

	for i := 0; i < n; {
		var cellName string
		fmt.Scanf("%s", &cellName)
		results := pattern1.FindStringSubmatch(cellName)
		if results != nil {
			row, _ = strconv.Atoi(results[1])
			col, _ = strconv.Atoi(results[2])
			fmt.Println(toPattern2(row, col))
			i++
			continue
		}

		results = pattern2.FindStringSubmatch(cellName)
		if results != nil {
			row, _ = strconv.Atoi(results[2])
			chars := []byte(results[1])
			counter := 0
			col = 0
			for j := len(chars) - 1; j >= 0; j-- {
				digit := float64(chars[j] - 'A' + 1)
				col += int(digit * math.Pow(26, float64(counter)))
				counter += 1
			}
			fmt.Println(toPattern1(row, col))
			i++
			continue
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
	"sync"
	"unicode"
)

const (
	maxn = int(1e5 + 50)
	mod  = int(1e9 + 7)
	eps  = 1e-8
	inf  = int(0x3f3f3f3f)
)

func main() {
	var T int
	scanInt(&T)
	for kase := 1; kase <= T; kase++ {
		s := scanString()
		t := 0
		tag := -1
		flag := false
		for i, x := range s {
			if !flag && unicode.IsDigit(x) {
				flag = true
				tag = i
			} else if flag && !unicode.IsDigit(x) {
				t = 1
				tag = i
				break
			}
		}
		if t == 0 {
			C := int64(0)
			for i := 0; i < tag; i++ {
				C = C * 26 + int64(s[i] - 'A' + 1)
			}
			putchar('R')
			printRuneSlice([]rune(s[tag:]), false)
			putchar('C')
			printlnInt64s(C)
		} else {
			C := int64(0)
			flag = false
			for i := tag + 1; i < len(s); i++ {
				C = C * 10 + int64(s[i] - '0')
			}
			var res []rune
			for C >= 26 {
				if C % 26 == 0 {
					res = append(res, 'Z')
					C = C / 26 - 1
				} else {
					res = append(res, rune('A' + C % 26 - 1))
					C /= 26
				}
			}
			if C > 0 {
				res = append(res, rune('A' + C - 1))
			}
			reverse(&res, 0, len(res))
			printRuneSlice(res, false)
			printRuneSlice([]rune(s[1:tag]), true)
		}
 	}
	close(channelType)
	oWg.Wait()
	out.Flush()
}

/*********************** I/O ***********************/

var channelType chan string
var in *bufio.Scanner
var out = bufio.NewWriter(os.Stdout)
var oWg *sync.WaitGroup

// string and slice are the return value
func init() {
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)
	channelType = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)
	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

		for line := range channelType {
			writer.WriteString(line + "\n")
		}
	}()
}
func scanString() string { in.Scan(); return in.Text() }
func scanInt(a *int)     { *a, _ = strconv.Atoi(scanString()) }
func scanInts(a ...*int) {
	for i := range a {
		*a[i], _ = strconv.Atoi(scanString())
	}
}
func scanInt64(a *int64) { *a, _ = strconv.ParseInt(scanString(), 10, 64) }
func scanInt64s(a ...*int64) {
	for i := range a {
		*a[i], _ = strconv.ParseInt(scanString(), 10, 64)
	}
}
func scanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = scanString()
	}
	return s
}
func scanIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		scanInt(&arr[i])
	}
	return arr
}
func scanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		scanInt64(&arr[i])
	}
	return arr
}
func printlnInts(args ...int) {
	for _, x := range args {
		fmt.Fprint(out, x, " ")
	}
	fmt.Fprintln(out)
}
func printlnInt64s(args ...int64) {
	for _, x := range args {
		fmt.Fprint(out, x, " ")
	}
	fmt.Fprintln(out)
}
func printIntSlice(a []int, flag bool) {
	for _, x := range a {
		fmt.Fprint(out, x, " ")
	}
	if flag { fmt.Fprintln(out) }
}
func printRuneSlice(a []rune, flag bool) {
	for _, x := range a {
		fmt.Fprintf(out, "%c", x)
	}
	if flag { fmt.Fprintln(out) }
}
func printInt64Slice(a []int64, flag bool) {
	for _, x := range a {
		fmt.Fprint(out, x, " ")
	}
	if flag { fmt.Fprintln(out) }
}
func putchar(a ...rune) {
	for _, x := range a {
		fmt.Fprintf(out, "%c", x)
	}
}
func printString(s string) { fmt.Fprintln(out, s) }

/*********************** Utils ***********************/

func stringEquivalent(v interface{}) string { return fmt.Sprintf("%v", v) }
func spaceSeperatedStringFromArray(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}
func spaceSeperatedStringFromArray64(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
	}
	return sb.String()
}
func minMaxFromArray(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func minElementFromArray(args ...int64) int64 { mn, _ := minMaxFromArray(args...); return mn }
func maxElementFromArray(args ...int64) int64 { _, mx := minMaxFromArray(args...); return mx }
func lcmCalculation(a, b int64) int64         { return a / gcdCalculation(a, b) * b }
func gcdCalculation(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return gcdCalculation(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func absoluteValue(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}
func min(args ...int) int { mn, _ := minMaxFinder(args...); return mn }
func max(args ...int) int { _, mx := minMaxFinder(args...); return mx }
func minMaxFinder(args ...int) (int, int) {
	minVal, maxVal := int(math.MaxInt32), int(math.MinInt32)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func same(x, y double) bool { return math.Abs(float64(x-y)) < eps }
func popcount(x int) (res int) {
	for i := 0; i < 32; i++ {
		if 1 == (1 & (x >> uint(i))) {
			res++
		}
	}
	return
}
func qp(a, n int64) (res int64) {
	for ; n > 0; n >>= 1 {
		if (n & 1) == 1 {
			res = res * a % int64(mod)
		}
		a = a * a % int64(mod)
	}
	return
}
func divUp(a, b int64) int64 {
	if a % b == 0 { return a / b } else { return a / b + 1 }
}
// [l, r)
func reverse(a *[]rune, l, r int) {
	for i, j := l, r - 1; i < j; i, j = i + 1, j - 1 {
		(*a)[i], (*a)[j] = (*a)[j], (*a)[i]
	}
}

/*********************** Structs ***********************/
type pair struct{ X, Y int }
type double float64
type pairSlice []pair

func (p pairSlice) Len() int { return len(p) }
func (p pairSlice) Less(i, j int) bool {
	if p[i].X != p[j].X {
		return p[i].X < p[j].X
	} else {
		return p[i].Y < p[j].Y
	}
}
func (p pairSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"regexp"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	scanner.Text()
	r, _ := regexp.Compile(`R\d+C\d+`)
	for scanner.Scan() {
		text := scanner.Text()
		notExcel := r.MatchString(text)
		if notExcel {
			convertExcelLikeSystem(text)
		} else {
			convertOtherSystem(text)
		}
	}
}

func convertOtherSystem(text string) {
	wr, _ := regexp.Compile(`\D+`)
	dr, _ := regexp.Compile(`\d+`)
	col := wr.FindAllString(text, -1)[0]
	row := dr.FindAllString(text, -1)[0]
	colNo := 0
	size := len(col) - 1
	for i, r := range col {
		dec := int(r) - 64
		colNo += dec * int(math.Pow(26, float64(size-i)))
	}

	fmt.Printf("R%sC%d\n", row, colNo)
}

func convertExcelLikeSystem(text string) {
	dr, _ := regexp.Compile(`\d+`)
	num := dr.FindAllString(text, -1)
	col, _ := strconv.Atoi(num[1])
	arr := make([]int, 0, 100)
	divide(col, &arr)
	str := ""
	for i, v := range arr {
		if v < 1 && i < len(arr) -1 {
			v = 27 - 1 + v
			arr[i+1]--
		}
		if v > 0 {
			str = string(v + 64) + str
		}
	}
	fmt.Printf("%s%s\n", str, num[0])
}

func divide(num int, arr *[]int){
	res := num/26
	mod := num % 26
	*arr = append(*arr, mod)
	if res > 0 {
		divide(res, arr)
	}
}

package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var n int
	var s string
	fmt.Scanf("%d\n", &n)
	for ; n > 0; n-- {
		fmt.Scanf("%s\n", &s)
		r := strings.Index(s, "R")
		c := strings.Index(s, "C")
		// like R23C55
		if r == 0 && c > 1 && strings.ContainsAny(s[1:c], "0123456789") {
			ri, _ := strconv.ParseInt(s[1:c], 10, 64)
			ci, _ := strconv.ParseInt(s[c+1:], 10, 64)
			transCi := transToABC(ci)
			fmt.Printf("%s%d\n", transCi, ri)
		} else { // like BC23
			m := strings.IndexAny(s, "0123456789")
			rs := s[m:]
			cs := s[:m]
			fmt.Printf("R%sC%d\n", rs, transFromABC(cs))
		}
	}
}

func transToABC(n int64) string {
	var res = make([]byte, 0, 30)
	for n > 0 {
		if n%26 == 0 {
			r := uint8('Z')
			res = append(res, r)
			n = n/26 - 1
		} else {
			r := uint8(n%26) + uint8('A') - 1
			res = append(res, r)
			n = n / 26
		}
	}
	i := 0
	j := len(res) - 1
	for i <= j {
		res[i], res[j] = res[j], res[i]
		i++
		j--
	}
	return string(res)
}

func transFromABC(s string) (res int) {
	for i := 0; i < len(s); i++ {
		res = res*26 + int(s[i]) - int('A') + 1
	}
	return res
}

package main

import "fmt"
import "bytes"

type Ref byte
const (
	ColRow Ref = iota
	RowCol
)

func excel_ref(row, col int) string {
	var buf bytes.Buffer

	for v := col; v > 0; v /= 26 {
		if v % 26 == 0 {
			buf.WriteByte('Z')
			v -= 1
		} else {
			buf.WriteByte(byte(v % 26) + '@')
		}
	}

	b := buf.Bytes()
	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
		b[j], b[i] = b[i], b[j]
	}

	return fmt.Sprintf("%s%d", buf.String(), row)
}

func convert(s string) string {
	row, col, mode := ref(s)
	if mode == ColRow {
		return fmt.Sprintf("R%dC%d", row, col)
	} else {
		return excel_ref(row, col)
	}
}

func ref(s string) (int, int, Ref) {
	if len(s) <= 1 {
		panic("Too short")
	}

	mode := ColRow
	var row, col int
	if s[0] == 'R' {
		i := 0
		for ; i < len(s) && (s[i] >= 'A') && (s[i] <= 'Z'); i++ {
			col = col * 26 + int(s[i] - '@')
		}

 		for ; i < len(s); i++ {
			if s[i] >= '0' && s[i] <= '9' {
				row = row * 10 + int(s[i] - '0')
			} else {
				break
			}
		}
		if i == len(s) {
			return row, col, mode
		}

		if s[i] != 'C' {
			panic("Malformed reference")
		}
		mode = RowCol
		i++
		col = 0
		for ; i < len(s); i++ {
			if s[i] >= '0' && s[i] <= '9' {
				col = col * 10 + int(s[i] - '0')
			} else {
				break
			}
		}

		return row, col, mode
	} else {
		var i int //, row, col int

		for i = 0; i < len(s) && (s[i] >= 'A') && (s[i] <= 'Z'); i++ {
			col = col * 26 + int(s[i] - '@')
		}

		for ; i < len(s); i++ {
			if s[i] >= '0' && s[i] <= '9' {
				row = row * 10 + int(s[i] - '0')
			} else {
				break
			}
		}
		return row, col, mode
	}
}

func main() {
	var n int
	var s string

	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%s\n", &s)
		fmt.Println(convert(s))
	}
}

package main

import (
	"fmt"
	"regexp"
	"strconv"
)

var (
	rFmt   = regexp.MustCompile("^([A-Z]+)([0-9]+)$")
	rNoFmt = regexp.MustCompile("^R([0-9]+)C([0-9]+)$")
)

type Data struct {
	n     int
	cells []Cell
}

type Cell struct {
	row    int
	column int
	fmt    bool
}

func main() {
	data := parse()
	for _, cell := range data.cells {
		switch cell.fmt {
		case true:
			fmt.Printf("R%dC%d\n", cell.row, cell.column)
		case false:
			column := cell.column
			strColumn := ""
			for column > 0 {
				strColumn = fmt.Sprintf("%c%s", 'A' + ((column-1) % 26), strColumn)
				column = ((column-1)/26)
			}
			fmt.Printf("%s%d\n", strColumn, cell.row)
		}
	}
}

func parse() Data {
	var data Data
	_, err := fmt.Scanf("%d\n", &data.n)
	if err != nil {
		panic(err)
	}

	data.cells = make([]Cell, data.n)
	for i := 0; i < data.n; i++ {
		var raw string
		_, err = fmt.Scanln(&raw)
		if err != nil {
			panic(err)
		}

		switch match, ok := isFmt(raw); ok {
		case true:
			data.cells[i].row, _ = strconv.Atoi(match[2])
			rawColumn := match[1]
			for j := range rawColumn {
				data.cells[i].column *= 26
				data.cells[i].column += int(rawColumn[j]) - 64
			}
			data.cells[i].fmt = true
		case false:
			data.cells[i].row, _ = strconv.Atoi(match[1])
			data.cells[i].column, _ = strconv.Atoi(match[2])
		}
	}
	return data
}

func isFmt(raw string) ([]string, bool) {
	match := rFmt.FindAllStringSubmatch(raw, 1)
	if match != nil {
		return match[0], true
	}

	match = rNoFmt.FindAllStringSubmatch(raw, 1)
	if match != nil {
		return match[0], false
	}

	panic(fmt.Errorf("unmatched"))
}

package main

import (
    "fmt"
	"strconv"
	"strings"
	"math"
)

func main(){
 var n int
	_, error:=fmt.Scanln(&n)

	if error!=nil{
		fmt.Println(error)
	}

	for i:=0;i<n;i++{
		var s string
		_, error:=fmt.Scanln(&s)
			if error!=nil{
			fmt.Println(error)
		}
		fmt.Println(translateString(s));
	}
}
	func translateString (input string) string {
		var xyType bool;
		var output string;
		x:=input[0:len(input)]
		if(x[0]=='R'){
			if _, err := strconv.Atoi(string(x[1])); err == nil {
				//This is could be R11 or R1C3 or R111111C3
					if _, err := strconv.Atoi(string(x[1:])); err == nil { //R110
						xyType=false;
					}else{//R12321C123
						xyType=true;
					}
			}else{
				xyType=false;
			}
		}
		if(xyType){
			output=toString26(input)
		}else{
			output=toXYfromRC(input)
		}
		return output
	}

	func toString26(x string) string{
			sp:=strings.Split(strings.Replace(strings.Replace(x,"R","",-1),"C"," ",-1)," ")
			 x=sp[1]
			 outR:=26
			 intx,_:=strconv.Atoi(x)
			 tmp:=intx
			 var intSlice []int
			 var result string
			 for {
				a:=tmp%outR
				tmp=tmp/outR
				if(a!=0){
					intSlice=append(intSlice,a)
				}else if (tmp>0){
					intSlice=append(intSlice,26)
					tmp=tmp-1
				}
				if(tmp==0){
					break;
				}
			 }
			 for i:=len(intSlice)-1;i>=0;i--{
				 result=result+string('A'+intSlice[i]-1)
			 }
			 result=result+sp[0]
			 return result
	}

	func toXYfromRC(x string) string {
		var i ,result ,exp int
		for i=0;i<=len(x);i++{
				if(x[i]<'A')||(x[i]>'Z'){
					break
				}
		}
		stringPart:=x[:i-1]
		for l:=len(stringPart);l>=0;l--{
			result+=(int(x[l])-'A'+1)* int(math.Pow(float64(26),float64(exp)))
			exp++
		}
		return "R"+x[i:len(x)]+"C"+strconv.Itoa(result)
	}

package main

import (
	"regexp"
	"fmt"
	"strconv"
	"math"
)

var patternMatch1 = regexp.MustCompile(`^([[:alpha:]]+)(\d+)$`)
var patternMatch2 = regexp.MustCompile(`^R(\d+)C(\d+)$`)

func main() {
	var times int
	fmt.Scanln(&times)
	for i := 0; i < times; i++ {
		var pattern string
		fmt.Scanln(&pattern)
		if matches := patternMatch1.FindStringSubmatch(pattern); matches != nil {
			var cResult int
			for j := len(matches[1]); j >= 1; j-- {
				cResult += (int(matches[1][j-1]) - int('A') + 1) * int(math.Pow(26, float64(len(matches[1])-j)))
			}
			fmt.Println("R" + matches[2] + "C" + strconv.Itoa(cResult))
		} else if matches := patternMatch2.FindStringSubmatch(pattern); matches != nil {
			var columns, _ = strconv.Atoi(matches[2])
			var cResult string
			for columns > 0 {
				index := If(columns % 26 == 0, 26, columns % 26).(int)
				cResult = string(index + int('A') - 1) + cResult
				columns = (columns - index) / 26
			}
			fmt.Println(cResult + matches[1])
		}
	}
}

func If(condition bool, trueVal, falseVal interface{}) interface{} {
	if condition {
		return trueVal
	}
	return falseVal
}

package main

import (
	"fmt"
)

func numTrans(str string) string {
	strLen := len(str)
	length := 0
	var str1, str2 string

	for ; length < strLen; length++ {
		ch := str[length]
		if (ch >= 'A') && (ch <= 'Z') {
			str1 += string(ch)
		} else {
			break
		}
	}

	for ; length < strLen; length++ {
		ch := str[length]
		if ch >= '0' && ch <= '9' {
			str2 += string(ch)
		} else {
			break
		}
	}

	if length == strLen {
		num := 0

		for _, c := range(str1) {
			num = num * 26 + int(c) - int('A') + 1
		}

		var col string

		for num > 0 {
			col = string('0' + byte(num - num / 10 * 10)) + col
			num /= 10
		}

		return "R" + str2 + "C" + col

	} else {
		col := str[length + 1:]
		num := 0

		for _,c := range(col) {
			num = num * 10 + int(c) - int('0')
		}

		var res string

		for num > 0 {
			mod := num % 26
			num /= 26

			if mod == 0 {
				res = "Z" + res
				num -= 1
			} else {
				res = string(byte(mod - 1) + 'A') + res
			}
		}

		return res + str2
	}
}

func main() {
	var lines int
	var str string

	fmt.Scanf("%d\n", &lines)

	for i := 0; i < lines; i++ {
		fmt.Scanf("%s\n", &str)
		//fmt.Println(str)
		fmt.Println(numTrans(str))
	}
}

package main

import (
	"fmt"
)

const (
	base = 'A' - 1
)

func getInt(str string) (result int64) {
	if i, _ := fmt.Sscanf(str, "%d", &result); i == 1 {
		return
	}
	panic("input invalid")
}

func isLetter(r byte) bool {
    return 'A' <= r && r <= 'Z'
}

func isDigit(r byte) bool {
    return '0' <= r && r <= '9'
}

func parse(s string) ([][]string) {
    parts := make([][]string, 0, 2)
    for start := 0; start < len(s); {
        pos := start
        for pos < len(s) && isLetter(s[pos]) {
            pos++
        }
        mark := pos
        for pos < len(s) && isDigit(s[pos]) {
            pos++
        }
        parts = append(parts, []string{s[start:mark], s[mark:pos]})
        start = pos
    }
    return parts
}

func transform(input string) string {
	ms := parse(input)
	switch len(ms) {
	case 1:
		return toRC(ms[0][0], getInt(ms[0][1]))
	case 2:
		return toXY(getInt(ms[0][1]), getInt(ms[1][1]))
	default:
		panic("input invalid")
	}
}

func itor(i int64) byte {
	return byte(i + base)
}

func rtoi(a byte) int64 {
	return int64(a - base)
}

func toRC(col string, rowNumber int64) string {
	var colNumber int64 = 0
	for _, a := range col {
		colNumber = colNumber*26 + rtoi(byte(a))
	}
	return fmt.Sprintf("R%dC%d", rowNumber, colNumber)
}

func toXY(row, col int64) string {
	bytes := make([]byte, 0, 6)
	for col > 0 {
		bytes = append(bytes, itor(((col-1)%26)+1))
		col = (col-1) / 26
	}
	for i, j := 0, len(bytes)-1; i < j; i, j = i+1, j-1 {
		bytes[i], bytes[j] = bytes[j], bytes[i]
	}
	return fmt.Sprintf("%s%d", string(bytes), row)
}

func main() {
	var n int64
	for fmt.Scanln(&n); n > 0; n-- {
		var input string
		fmt.Scanln(&input)
		fmt.Printf("%s\n", transform(input))
	}
}

package main

import (
	"fmt"
)

const (
	base = 'A' - 1
)

func getInt(str string) (result int64) {
	if i, _ := fmt.Sscanf(str, "%d", &result); i == 1 {
		return
	}
	panic("input invalid")
}

func isLetter(r byte) bool {
    return 'A' <= r && r <= 'Z'
}

func isDigit(r byte) bool {
    return '0' <= r && r <= '9'
}

func parse(s string) ([][]string) {
    parts := make([][]string, 0, 2)
    for start := 0; start < len(s); {
        pos := start
        for pos < len(s) && isLetter(s[pos]) {
            pos++
        }
        mark := pos
        for pos < len(s) && isDigit(s[pos]) {
            pos++
        }
        parts = append(parts, []string{s[start:mark], s[mark:pos]})
        start = pos
    }
    return parts
}

func transform(input string) string {
	ms := parse(input)
	switch len(ms) {
	case 1:
		return toRC(ms[0][0], getInt(ms[0][1]))
	case 2:
		return toXY(getInt(ms[0][1]), getInt(ms[1][1]))
	default:
		panic("input invalid")
	}
}

func itor(i int64) rune {
	return rune(i + base)
}

func rtoi(a rune) int64 {
	return int64(a - base)
}

func toRC(col string, rowNumber int64) string {
	var colNumber int64 = 0
	for _, a := range col {
		colNumber = colNumber*26 + rtoi(a)
	}
	return fmt.Sprintf("R%dC%d", rowNumber, colNumber)
}

func toXY(row, col int64) string {
	runes := make([]rune, 0, 6)
	for col > 0 {
		runes = append(runes, itor(((col-1)%26)+1))
		col = (col-1) / 26
	}
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return fmt.Sprintf("%s%d", string(runes), row)
}

func main() {
	var n int64
	for fmt.Scanln(&n); n > 0; n-- {
		var input string
		fmt.Scanln(&input)
		fmt.Printf("%s\n", transform(input))
	}
}

package main

import (
	"fmt"
	"regexp"
)

const (
	base = 'A' - 1
)

var (
	re = regexp.MustCompile(`([A-Z]+)([0-9]+)`)
)

func getInt(str string) (result int64) {
	if i, _ := fmt.Sscanf(str, "%d", &result); i == 1 {
		return
	}
	panic("input invalid")
}

func transform(input string) string {
	ms := re.FindAllStringSubmatch(input, -1)
	switch len(ms) {
	case 1:
		return toRC(ms[0][1], getInt(ms[0][2]))
	case 2:
		return toXY(getInt(ms[0][2]), getInt(ms[1][2]))
	default:
		panic("input invalid")
	}
}

func itor(i int64) rune {
	return rune(i + base)
}

func rtoi(a rune) int64 {
	return int64(a - base)
}

func toRC(col string, rowNumber int64) string {
	var colNumber int64 = 0
	for _, a := range col {
		colNumber = colNumber*26 + rtoi(a)
	}
	return fmt.Sprintf("R%dC%d", rowNumber, colNumber)
}

func toXY(row, col int64) string {
	runes := make([]rune, 0, 6)
	for col > 0 {
		runes = append(runes, itor(((col-1)%26)+1))
		col = (col-1) / 26
	}
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return fmt.Sprintf("%s%d", string(runes), row)
}

func main() {
	var n int64
	for fmt.Scanln(&n); n > 0; n-- {
		var input string
		fmt.Scanln(&input)
		fmt.Printf("%s\n", transform(input))
	}
}

package main

import (
	"fmt"
)

const (
	base = 'A' - 1
)

func getInt(str []byte) (result int64) {
    for _,b := range str {
        result = result * 10 + int64(b - '0')
    }
    return
}

func isLetter(r byte) bool {
    return 'A' <= r && r <= 'Z'
}

func isDigit(r byte) bool {
    return '0' <= r && r <= '9'
}

func parse(s []byte) ([][][]byte) {
    parts := make([][][]byte, 0, 2)
    for start := 0; start < len(s); {
        pos := start
        for pos < len(s) && isLetter(s[pos]) {
            pos++
        }
        mark := pos
        for pos < len(s) && isDigit(s[pos]) {
            pos++
        }
        parts = append(parts, [][]byte{s[start:mark], s[mark:pos]})
        start = pos
    }
    return parts
}

func transform(input []byte) string {
	ms := parse(input)
	switch len(ms) {
	case 1:
		return toRC(ms[0][0], getInt(ms[0][1]))
	case 2:
		return toXY(getInt(ms[0][1]), getInt(ms[1][1]))
	default:
		panic("input invalid")
	}
}

func itor(i int64) byte {
	return byte(i + base)
}

func rtoi(a byte) int64 {
	return int64(a - base)
}

func toRC(col []byte, rowNumber int64) string {
	var colNumber int64 = 0
	for _, a := range col {
		colNumber = colNumber*26 + rtoi(byte(a))
	}
	return fmt.Sprintf("R%dC%d", rowNumber, colNumber)
}

func toXY(row, col int64) string {
	bytes := make([]byte, 0, 6)
	for col > 0 {
		bytes = append(bytes, itor(((col-1)%26)+1))
		col = (col-1) / 26
	}
	for i, j := 0, len(bytes)-1; i < j; i, j = i+1, j-1 {
		bytes[i], bytes[j] = bytes[j], bytes[i]
	}
	return fmt.Sprintf("%s%d", string(bytes), row)
}

func main() {
	var n int64
	for fmt.Scanln(&n); n > 0; n-- {
		var input []byte
		fmt.Scanln(&input)
		fmt.Printf("%s\n", transform(input))
	}
}

package main

import (
	"fmt"
	"math"
	"strconv"
	"strings"
	"unicode"
)

func main() {
p1B()
}
// B. Spreadsheets
func p1B() {
	var input string
	var n int
	fmt.Scanf("%d\n", &n)
	for np := 0; np < n; np++ {
		fmt.Scanf("%s\n", &input)
		rIndex := strings.Index(input, "R")
		cIndex := strings.Index(input, "C")
		if rIndex == 0 && cIndex > 0 && unicode.IsDigit(rune(input[rIndex+1])) && unicode.IsDigit(rune(input[cIndex+1])) {
			colNum, _ := strconv.Atoi(input[cIndex+1:])
			fmt.Printf("%s%s\n", convertColNumberToAlpha(colNum), input[rIndex+1:cIndex])
		} else {
			col := ""
			row := ""
			for i := 0; i < len(input); i++ {
				if input[i] >= 'A' && input[i] <= 'Z' {
					col += string(input[i])
				} else {
					row += string(input[i])
				}
			}
			fmt.Printf("R%sC%d\n", row, convertToNum(col))
		}
	}
}

func convertColNumberToAlpha(input int) string {
	result := ""
	for input > 0 {
		mod := input % 26
		if mod > 0 {
			result = string(mod+64) + result
		} else {
			input -= 26
			result = "Z" + result
		}
		input /= 26
	}
	return result
}

func convertToNum(input string) int {
	result := 0
	for i := len(input) - 1; i >= 0; i-- {
		charM := int(input[i]-'A') + 1
		result += int(math.Pow(26, float64(len(input)-1-i))) * charM
	}
	return result
}

/*
  1.B. Электронные таблицы
  http://codeforces.ru/contest/1/problem/B
*/
package main

import (
  "fmt"
  "strconv"
)

func Atoi(s string) int {
  ret, err := strconv.Atoi(s)
  if err != nil { panic(err) }
  return ret
}

func IsAlpha(s string) bool {
  f := true
  for _, char := range s {
    if '0' <= char && char <= '9' {
      f = false
    } else {
      if !f { return false }
    }
  }
  return true
}

func NumParse(s string) (r, c int) {
  f := false
  for _, char := range s {
    v := int(char - '0')
    switch char {
      case 'R': continue
      case 'C': f = true
      default:
        if f {
          c = c * 10 + v
        } else {
          r = r * 10 + v
        }
    }
  }
  return
}

func AlphaParse(s string) (r int, c string) {
  for _, char := range s {
    if '0' <= char && char <= '9' {
      r = r * 10 + int(char - '0')
    } else {
      c = c + string(char)
    }
  }
  return
}

func ColI2A(n int) (ret string) {
  for n > 0 {
    ret = string('A' + (n + 25) % 26) + ret
    n = (n - 1) / 26
  }
  return
}

func ColA2I(n string) (ret int) {
  for _, char := range n {
    ret = ret * 26 + int(char - 'A' + 1)
  }
  return
}

func NumToAlpha(s string) string {
  r, c := NumParse(s)
  return fmt.Sprintf(
    "%s%d",
    ColI2A(c),
    r,
  )
}

func AlphaToNum(s string) string {
  r, c := AlphaParse(s)
  return fmt.Sprintf(
    "R%dC%d",
    r,
    ColA2I(c),
  )
}

func Convert(s string) string {
  if !IsAlpha(s) {
    return NumToAlpha(s)
  } else {
    return AlphaToNum(s)
  }
}

func Solution(n int, s []string) (ret []string) {
  ret = make([]string, n)
  for i, str := range s {
    ret[i] = Convert(str)
  }
  return
}

func main() {
  var n int
  fmt.Scanf("%d\n", &n)
  s := make([]string, 0, n)
  for i := 0; i < n; i++ {
    var str string
    fmt.Scanf("%s\n", &str)
    s = append(s, str)
  }
  ret := Solution(n, s)
  for _, str := range ret {
    fmt.Println(str)
  }
}

/*
  1.B. Электронные таблицы
  http://codeforces.ru/contest/1/problem/B
*/
package main

import (
  "fmt"
)

func IsAlpha(s string) bool {
  f := true
  for _, char := range s {
    if '0' <= char && char <= '9' {
      f = false
    } else {
      if !f { return false }
    }
  }
  return true
}

func NumParse(s string) (r, c int) {
  f := false
  for _, char := range s {
    v := int(char - '0')
    switch char {
      case 'R': continue
      case 'C': f = true
      default:
        if f {
          c = c * 10 + v
        } else {
          r = r * 10 + v
        }
    }
  }
  return
}

func AlphaParse(s string) (r int, c string) {
  for _, char := range s {
    if '0' <= char && char <= '9' {
      r = r * 10 + int(char - '0')
    } else {
      c = c + string(char)
    }
  }
  return
}

func ColI2A(n int) (ret string) {
  for n > 0 {
    ret = string('A' + (n + 25) % 26) + ret
    n = (n - 1) / 26
  }
  return
}

func ColA2I(n string) (ret int) {
  for _, char := range n {
    ret = ret * 26 + int(char - 'A' + 1)
  }
  return
}

func NumToAlpha(s string) string {
  r, c := NumParse(s)
  return fmt.Sprintf(
    "%s%d",
    ColI2A(c),
    r,
  )
}

func AlphaToNum(s string) string {
  r, c := AlphaParse(s)
  return fmt.Sprintf(
    "R%dC%d",
    r,
    ColA2I(c),
  )
}

func Convert(s string) string {
  if !IsAlpha(s) {
    return NumToAlpha(s)
  } else {
    return AlphaToNum(s)
  }
}

func main() {
  var n int
  fmt.Scanf("%d\n", &n)
  for i := 0; i < n; i++ {
    var str string
    fmt.Scanf("%s\n", &str)
    fmt.Println(Convert(str))
  }
}

/*
  1.B. Электронные таблицы
  http://codeforces.ru/contest/1/problem/B
*/
package main

import (
  "fmt"
)

func Atoi(s string) (ret int) {
  for _,  char := range s {
    ret = ret * 10 + int(char - '0')
  }
  return
}

func IsAlpha(s string) bool {
  f := true
  for _, char := range s {
    if '0' <= char && char <= '9' {
      f = false
    } else {
      if !f { return false }
    }
  }
  return true
}

func NumParse(s string) (r, c int) {
  f := false
  for _, char := range s {
    v := int(char - '0')
    switch char {
      case 'R': continue
      case 'C': f = true
      default:
        if f {
          c = c * 10 + v
        } else {
          r = r * 10 + v
        }
    }
  }
  return
}

func AlphaParse(s string) (r int, c string) {
  for _, char := range s {
    if '0' <= char && char <= '9' {
      r = r * 10 + int(char - '0')
    } else {
      c = c + string(char)
    }
  }
  return
}

func ColI2A(n int) (ret string) {
  for n > 0 {
    ret = string('A' + (n + 25) % 26) + ret
    n = (n - 1) / 26
  }
  return
}

func ColA2I(n string) (ret int) {
  for _, char := range n {
    ret = ret * 26 + int(char - 'A' + 1)
  }
  return
}

func NumToAlpha(s string) string {
  r, c := NumParse(s)
  return fmt.Sprintf(
    "%s%d",
    ColI2A(c),
    r,
  )
}

func AlphaToNum(s string) string {
  r, c := AlphaParse(s)
  return fmt.Sprintf(
    "R%dC%d",
    r,
    ColA2I(c),
  )
}

func Convert(s string) string {
  if !IsAlpha(s) {
    return NumToAlpha(s)
  } else {
    return AlphaToNum(s)
  }
}

func Solution(n int, s []string) (ret []string) {
  ret = make([]string, n)
  for i, str := range s {
    ret[i] = Convert(str)
  }
  return
}

func main() {
  var n int
  fmt.Scanf("%d\n", &n)
  for i := 0; i < n; i++ {
    var str string
    fmt.Scanf("%s\n", &str)
    fmt.Println(Convert(str))
  }
}

/*
  1.B. Электронные таблицы
  http://codeforces.ru/contest/1/problem/B
*/
package main

import (
  "fmt"
  "regexp"
  "strconv"
)

var NumRE = regexp.MustCompile("^R(\\d+)C(\\d+)$")
var AlphaRE = regexp.MustCompile("^([A-Z]+)(\\d+)$")

func Atoi(s string) int {
  ret, err := strconv.Atoi(s)
  if err != nil { panic(err) }
  return ret
}

func ColI2A(n int) (ret string) {
  k, s, p := 1, 0, 26
  for s + p < n {
    s += p
    p *= 26
    k++
  }
  n -= s + 1
  for k > 0 {
    ret = string('A' + (n % 26)) + ret
    n /= 26
    k--
  }
  return
}

func ColA2I(n string) (ret int) {
  for _, char := range n {
    ret = ret * 26 + int(char - 'A')
  }
  p := 1
  for i := 0; i < len(n); i++ {
    ret += p
    p *= 26
  }
  return
}

func NumToAlpha(s string) string {
  parse := NumRE.FindStringSubmatch(s)
  return fmt.Sprintf(
    "%s%s",
    ColI2A(Atoi(parse[2])),
    parse[1],
  )
}

func AlphaToNum(s string) string {
  parse := AlphaRE.FindStringSubmatch(s)
  return fmt.Sprintf(
    "R%sC%d",
    parse[2],
    ColA2I(parse[1]),
  )
}

func Convert(s string) string {
  if NumRE.MatchString(s) {
    return NumToAlpha(s)
  } else {
    return AlphaToNum(s)
  }
}

func Solution(n int, s []string) (ret []string) {
  ret = make([]string, n)
  for i, str := range s {
    ret[i] = Convert(str)
  }
  return
}

func main() {
  var n int
  s := make([]string, 0, 128)
  fmt.Scanf("%d", &n)
  for i := 0; i < n; {
    var str string
    _, err := fmt.Scanf("%s", &str)
    if err == nil {
      s = append(s, str)
      i++
    }
  }
  ret := Solution(n, s)
  for _, str := range ret {
    fmt.Println(str)
  }
}

/*
  1.B. Электронные таблицы
  http://codeforces.ru/contest/1/problem/B
*/
package main

import (
  "fmt"
)

func Atoi(s string) (ret int) {
  for _,  char := range s {
    ret = ret * 10 + int(char - '0')
  }
  return
}

func IsAlpha(s string) bool {
  f := true
  for _, char := range s {
    if '0' <= char && char <= '9' {
      f = false
    } else {
      if !f { return false }
    }
  }
  return true
}

func NumParse(s string) (r, c int) {
  f := false
  for _, char := range s {
    v := int(char - '0')
    switch char {
      case 'R': continue
      case 'C': f = true
      default:
        if f {
          c = c * 10 + v
        } else {
          r = r * 10 + v
        }
    }
  }
  return
}

func AlphaParse(s string) (r int, c string) {
  for _, char := range s {
    if '0' <= char && char <= '9' {
      r = r * 10 + int(char - '0')
    } else {
      c = c + string(char)
    }
  }
  return
}

func ColI2A(n int) (ret string) {
  for n > 0 {
    ret = string('A' + (n + 25) % 26) + ret
    n = (n - 1) / 26
  }
  return
}

func ColA2I(n string) (ret int) {
  for _, char := range n {
    ret = ret * 26 + int(char - 'A' + 1)
  }
  return
}

func NumToAlpha(s string) string {
  r, c := NumParse(s)
  return fmt.Sprintf(
    "%s%d",
    ColI2A(c),
    r,
  )
}

func AlphaToNum(s string) string {
  r, c := AlphaParse(s)
  return fmt.Sprintf(
    "R%dC%d",
    r,
    ColA2I(c),
  )
}

func Convert(s string) string {
  if !IsAlpha(s) {
    return NumToAlpha(s)
  } else {
    return AlphaToNum(s)
  }
}

func main() {
  var n int
  fmt.Scanf("%d\n", &n)
  for i := 0; i < n; i++ {
    var str string
    fmt.Scanf("%s\n", &str)
    fmt.Println(Convert(str))
  }
}

/*
  1.B. Электронные таблицы
  http://codeforces.ru/contest/1/problem/B
*/
package main

import (
  "fmt"
  "regexp"
  "strconv"
)

var NumRE = regexp.MustCompile("^R(\\d+)C(\\d+)$")
var AlphaRE = regexp.MustCompile("^([A-Z]+)(\\d+)$")

func Atoi(s string) int {
  ret, err := strconv.Atoi(s)
  if err != nil { panic(err) }
  return ret
}

func ColI2A(n int) (ret string) {
  for n > 0 {
    ret = string('A' + (n + 25) % 26) + ret
    n = (n - 1) / 26
  }
  return
}

func ColA2I(n string) (ret int) {
  for _, char := range n {
    ret = ret * 26 + int(char - 'A' + 1)
  }
  return
}

func NumToAlpha(s string) string {
  parse := NumRE.FindStringSubmatch(s)
  return fmt.Sprintf(
    "%s%s",
    ColI2A(Atoi(parse[2])),
    parse[1],
  )
}

func AlphaToNum(s string) string {
  parse := AlphaRE.FindStringSubmatch(s)
  return fmt.Sprintf(
    "R%sC%d",
    parse[2],
    ColA2I(parse[1]),
  )
}

func Convert(s string) string {
  if NumRE.MatchString(s) {
    return NumToAlpha(s)
  } else {
    return AlphaToNum(s)
  }
}

func Solution(n int, s []string) (ret []string) {
  ret = make([]string, n)
  for i, str := range s {
    ret[i] = Convert(str)
  }
  return
}

func main() {
  var n int
  s := make([]string, 0, 128)
  fmt.Scanf("%d\n", &n)
  for i := 0; i < n; i++ {
    var str string
    fmt.Scanf("%s\n", &str)
    s = append(s, str)
  }
  ret := Solution(n, s)
  for _, str := range ret {
    fmt.Println(str)
  }
}

package main

import "fmt"

var pows = []int{1, 26, 676, 17576, 456976, 11881376}

func main() {
	var n int
	var s string

	_, _ = fmt.Scanf("%d\n", &n)

	for i:=0; i<n; i++ {
		_, _ = fmt.Scanf("%s\n", &s)
		sr, ir, sc, ic := parse(s)
		if sc == "" {
			fmt.Printf("R%dC%d\n", ir, decodeCol(sr))
		} else {
			fmt.Printf("%s%d\n", encodeCol(ic), ir)
		}

	}
}

func parse(s string) (sr string, ir int, sc string, ic int) {
	n := len(s)
	var c uint8
	i := 0

	next := func() {
		if i >= n {
			c = 0
		} else {
			c = s[i]
		}
		i++
	}

	next()
	for isLetter(c) {
		sr += string(c)
		next()
	}

	for isDigit(c) && i <= n  {
		ir = (ir * 10) + int(c - '0')
		next()
	}

	for isLetter(c) {
		sc += string(c)
		next()
	}

	for isDigit(c) && i <= n  {
		ic = (ic * 10) + int(c - '0')
		next()
	}

	return
}

func isDigit(c uint8) bool {
	return c >= '0' && c <= '9'
}

func isLetter(c uint8) bool {
	return c >= 'A' && c <= 'Z'
}

func encodeCol(a int) string {
	s := ""
	for a > 0 {
		a--
		d := a % 26
		a = a / 26
		s = string(d + int('A')) + s
	}
	return s
}

func decodeCol(a string) int {
	s := 0
	n := len(a) - 1
	for i, c := range a {
		s += pows[n - i] * (int(c) - int('A') + 1)
	}
	return s
}

//2b
package main

import (
	"fmt"
	"regexp"
	"strconv"
)

var reg1, reg2 *regexp.Regexp
var base map[byte]int
var basestr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
var buf []byte

func convert(s string) string {
	a := reg1.FindStringSubmatch(s)
	if len(a) != 0 { //WD
		c := 0
		r, _ := strconv.Atoi(a[2])
		for i := 0; i < len(a[1]); i++ {
			c *= 26
			c += base[a[1][i]] + 1
		}
		return fmt.Sprintf("R%dC%d", r, c)
	}

	b := reg2.FindStringSubmatch(s) //RC
	r, _ := strconv.Atoi(b[1])
	c, _ := strconv.Atoi(b[2])
	i := 7

	for c != 0 {
		c--
		buf[i] = basestr[c%26]
		c /= 26
		i--
	}

	return fmt.Sprintf("%s%d", buf[i+1:], r)
}

func main() {

	reg1, _ = regexp.Compile(`^([A-Z]+)(\d+)$`)
	reg2, _ = regexp.Compile(`^R(\d+)C(\d+)$`)
	base = make(map[byte]int, 0)
	for i := 'A'; i <= 'Z'; i++ {
		base[byte(i)] = int(i - 'A')
	}
	buf = make([]byte, 8)
	n := 0
	fmt.Scanf("%d\n", &n)
	s := make([]string, n)
	for i := 0; i < len(s); i++ {
		fmt.Scanf("%s\n", &s[i])
	}
	for _, value := range s {
		fmt.Println(convert(value))
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"regexp"
	"strconv"
	"strings"
)

// Solve computes the column conversions
func Solve(s string) string {
	if IsDecimalColumn(s) {
		row := strings.Split(s, "C")[0][1:]
		column, _ := strconv.Atoi(strings.Split(s, "C")[1])
		return DecToExcelBase26(column) + row
	}
	//split s into base26 section and decimal section
	col := GetColumn(s)
	row := GetRow(s)
	return "R" + row + "C" + strconv.Itoa(Base26ToDecimal(col))
}

// IsDecimalColumn checks if the input string is like "R23C55" format
func IsDecimalColumn(s string) bool {
	result, _ := regexp.MatchString(`^R\d{1,}C\d{1,}$`, s)
	return result
}

// DecToExcelBase26 converts decimal to the weird Excel Base26 format
func DecToExcelBase26(n int) string {
	if n < 1 {
		return ""
	}
	var c string
	for n > 0 {
		c = string((n-1)%26+65) + c
		n = (n - 1) / 26
	}
	return c
}

// Base26ToDecimal converts base 26 representation into a decimal column id
func Base26ToDecimal(s string) int {
	reversed := Reverse(s)
	accu := 0
	for i := 0; i < len(reversed); i++ {
		accu += (int(reversed[i]-64) * int(math.Pow(26, float64(i))))
	}
	return accu
}

// GetRow returns the row suffix of "23" from a string in "BC23" form
func GetRow(s string) string {
	for i := 0; i < len(s); i++ {
		result, _ := regexp.MatchString(`\d`, string(s[i]))
		if result {
			return s[i:]
		}
	}
	return ""
}

// GetColumn returns the column prefix of "BC" from a string in "BC23" form
func GetColumn(s string) string {
	for i := 0; i < len(s); i++ {
		result, _ := regexp.MatchString(`\d`, string(s[i]))
		if result {
			return s[:i]
		}
	}
	return s
}

// Reverse reverses a string the "go" way :/
func Reverse(s string) string {
	chars := []rune(s)
	for i, j := 0, len(chars)-1; i < j; i, j = i+1, j-1 {
		chars[i], chars[j] = chars[j], chars[i]
	}
	return string(chars)
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < n; i++ {
		scanner.Scan()
		fmt.Println(Solve(scanner.Text()))
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
	"unicode"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)

	// The number of test cases
	var numCases int
	fmt.Fscanf(in, "%d\n", &numCases)

	// Handle each test case
	var s string
	a := make([]rune, 0, 1000)
	for i := 0; i < numCases; i++ {
		fmt.Fscanf(in, "%s\n", &s)

		// R23C55 -> BC23
		p := strings.Index(s, "C")
		if 'R' == s[0] && '0' <= s[1] && s[1] <= '9' && 1 < p && p < len(s) {
			r, _ := strconv.Atoi(s[1:p])
			c, _ := strconv.Atoi(s[p+1:])

			a = a[:0]
			for c > 0 {
				if c%26 == 0 {
					a = append(a, 'Z')
					c = (c - 1) / 26
				} else {
					a = append(a, rune('A'+(c%26-1)))
					c /= 26
				}
			}

			for i := range a {
				fmt.Fprintf(out, "%c", a[len(a)-i-1])
			}

			fmt.Fprintf(out, "%d\n", r)

		} else { // BC23 -> R23C55
			p := strings.IndexFunc(s, unicode.IsDigit)
			row := s[0:p]
			col := s[p:]

			c := 0
			for _, v := range row {
				c = c*26 + int(v-'A'+1)
			}

			fmt.Fprintf(out, "R%sC%d\n", col, c)
		}
	}

	out.Flush()
}

//  URL: http://codeforces.com/problemset/problem/1/B
//  PROBLEM RESTATEMENT
//      Spreadsheets use two naming systems. Task is to convert between them.
//      Format 1:
//          Columns numbered A ... Z, AA ... AZ, BA .... BZ, etc.
//          Rows numbered using integer numbers starting at 1.
//      Format 2:
//          R followed by row number, C followed by column number.
//  APPROACH
//      The problem is asking to convert between base 26 and base 10.

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"regexp"
	"strconv"
)

func letterToPosition(s byte) int {
	return int(rune(s) - 64)
}

func convertExcelColumnToInt(s string) int {
	exponent := 0
	value := 0
	for i := len(s) - 1; i >= 0; i-- {
		charValue := letterToPosition(s[i])
		value += charValue * int(math.Pow(26, float64(exponent)))
		exponent += 1
	}
	return value
}

func convertIntToExcelColumn(n int) (excelColumn string) {
	for n > 0 {
		excelColumn = string('A'+(n+25)%26) + excelColumn
		n = (n - 1) / 26
	}
	return
}

func main() {
	reader, writer := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var n int
	var s string
	fmt.Fscanf(reader, "%d\n", &n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%s\n", &s)
		excelMatch := regexp.MustCompile(`^(\D+)(\d+)$`).FindStringSubmatch(s)
		rcMatch := regexp.MustCompile(`^R([0-9]+)C([0-9]+)$`).FindStringSubmatch(s)
		if excelMatch != nil {
			fmt.Fprintf(writer, "R%sC%d\n", excelMatch[2], convertExcelColumnToInt(excelMatch[1]))
		} else if rcMatch != nil {
			column, _ := strconv.Atoi(rcMatch[2])
			fmt.Fprintf(writer, "%s%s\n", convertIntToExcelColumn(column), rcMatch[1])
		}
	}
}

package main

import (
	"fmt"
	"strconv"
)

func Reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func Convert1(r int, c int) {
	var column string
	cr, cq := (c-1)/26, (c-1)%26
	column += string(cq + 'A')

	for cr != 0 {
		cr, cq = (cr-1)/26, (cr-1)%26
		column += string(cq + 'A')
	}

	fmt.Printf("%s%d\n", Reverse(column), r)
}

func Convert2(r int, c string) {
	var column int
	for _, sc := range c {
		column = column*26 + int(sc -'A') + 1
	}

	fmt.Printf("R%dC%d\n", r, column)
}

func main() {
	var n int
	var cells []string

	fmt.Scanf("%d\n", &n)

	for i := 0; i < n; i += 1 {
		var s string
		fmt.Scanf("%s\n", &s)
		cells = append(cells, s)
	}

	for _, cell := range cells {
		var r, c int
		var row string
		if read, _ := fmt.Sscanf(cell, "R%dC%d", &r, &c); read == 2 {
			Convert1(r, c)
		} else {
			var column string
			for _, cc := range cell {
				if 'A' <= cc && cc <= 'Z' {
					column += string(cc)
				} else {
					row += string(cc)
				}
			}
			r, _ = strconv.Atoi(row)
			Convert2(r, column)
		}
	}
}

package main
import (
    "fmt"
    "strconv")

// R23C55 type 1
// BC23 type 2

func dumpData(data []string) {
    for i:=0; i<len(data); i++ {
        fmt.Printf("data[%d] = '%s'\n", i, data[i])
    }
}

func isDigit(c byte) bool {
    return c>='0' && c<='9'
}

func parse(s string) int {
    var c int = 0
    var lastDigit bool = false
    data := []string{"", "", "", ""}
    var form int
    //dumpData(data)
    for i:=0; i<len(s); i++{
        digit := isDigit(s[i])
        if digit {
            if lastDigit {
                data[c] = data[c] + string(s[i])
            } else {
                c++
                data[c] = data[c] + string(s[i])
            }
        } else {
            if lastDigit {
                c++
                data[c] = data[c] + string(s[i])
            } else {
                data[c] = data[c] + string(s[i])
            }

        }
        lastDigit = digit
        //
    }
    //dumpData(data)

    if data[2] == "" {
        form = 2
        r, _ := strconv.ParseInt(data[1], 10, 64)
        c := int64(azToInt(data[0]))
        fmt.Printf("R%dC%d\n", r, c)
    } else {
        form = 1

        r, _ := strconv.ParseInt(data[3], 10, 64)
        x := intToAz(r)
        y := data[1]
        fmt.Printf("%s%s\n", x, y)
    }
    return form
}

func azToInt(az string) int64 {
    var res int64 = 0
    for n := 0; n<len(az); n++ {
        t := charTo26(az[n])
        res = 26*res + t
    }
    return res
}

func charTo26(char byte) int64 {
    return int64(1 + char - byte('A'))
}

func intTo26(n int64) string {
    if n==0 {
        return ""
    } else {
        return string(byte(n) + byte('A')-1)
    }
}

func intToAz(n int64) string {
    var res string = ""
    var d int64 = n
    for ;d!=0; {
        dd := d % 26
        ddd := d / 26
        if dd != 0 {
            res = intTo26(dd) + res
        } else {
            res = intTo26(26) + res
            ddd = ddd - 1
        }

        d = ddd
    }
    return res
}

func main() {

    //fmt.Println(intToAz(494))

    var s string
    var i, c int64
    fmt.Scanf("%d", &c)
    for i=1; i<=c; i++ {
        fmt.Scanf("\n%s", &s)
        parse(s)
    }
}

package main

import "fmt"
import "regexp"
import "bytes"

func itos(v int) string{

 var sb bytes.Buffer

 for v > 0 {

  sb.WriteByte((byte)('A' + (v + 25) % 26))

  if (v % 26 == 0) {
    v -= 26
  }

  v /= 26
 }

 bs := sb.Bytes()
 i := 0
 j := len(bs) - 1

 for ; i < j ; {
	 bs[i],bs[j] =bs[j],bs[i]
	 i++
	 j--
 }

 return sb.String()
}

func stoi(s string) int{

  v := int(0)
  m := int(1)

  for i := len(s) - 1; i >= 0; i-- {

    v += m * ((int)(s[i] - 'A') + 1)
    m *= 26;
  }

  return v;

}

func main(){

	var n int
	fmt.Scanf("%d\n",&n)
	re := regexp.MustCompile("(R\\d+C\\d+)|(([A-Z]+)(\\d+))")

	for i := 0 ; i < n ; i ++ {

	  var k string
		fmt.Scanf("%s\n",&k)

		ss := re.FindStringSubmatch(k)

		if len(ss[1]) > 0  {
			var a,b int
			fmt.Sscanf(ss[1],"R%dC%d",&a,&b)
			fmt.Printf("%s%d\n",itos(b),a)
		}

		if len(ss[2]) > 0 {
			a := ss[3]
			var b int
			fmt.Sscanf(ss[4],"%d",&b)
			fmt.Printf("R%dC%d\n",b,stoi(a))
		}
	}

}

package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var t int
	fmt.Scan(&t)

	var s string
	for z := 0; z < t; z++ {
		fmt.Scan(&s)

		if strings.Contains(s, "R") && strings.Contains(s, "C") &&
			(s[1] >= '1' && s[1] <= '9') {
			// R23C55 case
			ri := strings.Index(s, "R")
			ci := strings.Index(s, "C")
			row := s[ri+1 : ci]
			col := s[ci+1:]
			c, _ := strconv.Atoi(col)

			var b []byte
			for ; c > 26; c /= 26 {
				char := c % 26
				if char == 0 {
					b = append([]byte{byte('Z')}, b...)
					c -= 26
				} else {
					b = append([]byte{byte(char + 'A' - 1)}, b...)
				}
			}
			b = append([]byte{byte(c + 'A' - 1)}, b...)
			fmt.Printf("%s%s\n", b, row)

		} else {
			// BC23
			// 2*26 + 3
			var ri int
			for k, v := range s {
				if v >= '0' && v <= '9' {
					ri = k
					break
				}
			}
			col := s[:ri]
			row := s[ri:]

			var sum int
			for i, j := len(col)-1, 1; i >= 0; i, j = i-1, j*26 {
				sum += int(col[i]-'A'+1) * j
			}
			fmt.Printf("R%sC%d\n", row, sum)
		}

	}

}

package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)
	for in := 0; in < n; in++ {

		var s string
		fmt.Scan(&s)

		var first_num, second_num, second_ab int
		for first_num = 0; first_num < len(s); first_num++ {
			if !('A' <= s[first_num] && s[first_num] <= 'Z') {
				break
			}
		}
		flag := false
		for second_ab = first_num + 1; second_ab < len(s); second_ab++ {
			if 'A' <= s[second_ab] && s[second_ab] <= 'Z' {
				flag = true
				break
			}
		}
		for second_num = len(s) - 1; second_num >= 0; second_num-- {
			if 'A' <= s[second_num-1] && s[second_num-1] <= 'Z' {
				break
			}
		}

		if flag {
			c, _ := strconv.Atoi(s[second_num:])

			r := []int{}
			for c > 0 {
				cc := c % 26
				if cc == 0 {
					cc = 26
					c--
				}
				r = append(r, cc)
				c = c / 26
			}
			for ir := len(r) - 1; ir >= 0; ir-- {
				fmt.Printf("%c", int('A')+r[ir]-1)
			}
			fmt.Println(s[first_num:second_ab])
		} else {
			c := s[:first_num]
			var res int64
			res = 0
			for _, cc := range c {
				res = res*26 + int64(cc) - int64('A') + 1
			}
			fmt.Printf("R%sC%d\n", s[first_num:], res)
		}
	}
}

package main

import (
	"bufio"
	"io"
	"os"
	"strconv"
	"strings"
	"fmt"
	"regexp"
	"math"
)

////////////////////////////////////////////////////////////////////////////////

// INPUT TEMPLATE START

type MyInput struct {
	rdr         io.Reader
	lineChan    chan string
	initialized bool
}

func (mi *MyInput) start(done chan struct{}) {
	r := bufio.NewReader(mi.rdr)
	defer func() {
		close(mi.lineChan)
	}()
	for {
		line, err := r.ReadString('\n')
		if !mi.initialized {
			mi.initialized = true
			done <- struct{}{}
		}
		mi.lineChan <- strings.TrimSpace(line)
		if err == io.EOF {
			break
		}
		if err != nil {
			panic(err)
		}
	}
}

func (mi *MyInput) readLine() string {
	// if this is the first call, initialize
	if !mi.initialized {
		mi.lineChan = make(chan string)
		done := make(chan struct{})
		go mi.start(done)
		<-done
	}

	res, ok := <-mi.lineChan
	if !ok {
		panic("trying to read from a closed channel")
	}
	return res
}

func (mi *MyInput) readInt() int {
	line := mi.readLine()
	i, err := strconv.Atoi(line)
	if err != nil {
		panic(err)
	}
	return i
}

func (mi *MyInput) readInt64() int64 {
	line := mi.readLine()
	i, err := strconv.ParseInt(line, 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (mi *MyInput) readInts() []int {
	line := mi.readLine()
	parts := strings.Split(line, " ")
	res := []int{}
	for _, s := range parts {
		tmp, err := strconv.Atoi(s)
		if err != nil {
			panic(err)
		}
		res = append(res, tmp)
	}
	return res
}

func (mi *MyInput) readInt64s() []int64 {
	line := mi.readLine()
	parts := strings.Split(line, " ")
	res := []int64{}
	for _, s := range parts {
		tmp, err := strconv.ParseInt(s, 10, 64)
		if err != nil {
			panic(err)
		}
		res = append(res, tmp)
	}
	return res
}

func (mi *MyInput) readWords() []string {
	line := mi.readLine()
	return strings.Split(line, " ")
}

// INPUT TEMPLATE END

////////////////////////////////////////////////////////////////////////////////

func main() {

	/*fmt.Println(int('B'))
	fmt.Println(int('0'))
	fmt.Println(int('1'))
*/

	//solve("R228C494") //RZ228
	//solve("ZZ26")
	//solve("R2C28")
	//solve("R26C26")
	//solve("R26C701")
	/*tn := time.Now()
	solve([]int64{1000000000, 1000000000, 1})
	log.Println(time.Since(tn))
	return*/
	mi := MyInput{rdr: os.Stdin}
	t := mi.readInt()

	for caseNo := 1; caseNo <= t; caseNo++ {
		solve(mi.readLine())
	}

}

func solve(cell string) {
	if match, _ := regexp.MatchString("R\\d+C\\d+", cell); match {
		mat := regexp.MustCompile("R(\\d+)C(\\d+)").FindAllStringSubmatch(cell, -1)[0]
		r := mat[1]
		c := mat[2]
		dividend,_ := strconv.Atoi(c);
		columnName := "";
		var modulo int;

		for ; (dividend > 0); {
			modulo = (dividend - 1) % 26;
			columnName = string(65 + modulo) + columnName;
			dividend = (int)((dividend - modulo) / 26);
		}

		fmt.Println(columnName + r)

	} else {

		mat := regexp.MustCompile("([A-Z]+)(\\d+)").FindAllStringSubmatch(cell, -1)[0]
		r := mat[1]
		c := mat[2]

		r2 := float64(0)
		for i, ch := range r {
			x := int(ch) - 64
			r2 += math.Pow(26, float64(len(r) - i - 1)) * float64(x)
		}
		fmt.Printf("R%sC%d\n", c, int(r2))
		//CCNN
	}

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

func I(i ...interface{}) error {
	_, err := fmt.Fscan(r, i...)
	return err
}

func O(o ...interface{}) {
	fmt.Fprint(w, o...)
}

var (
	r *bufio.Reader
	w *bufio.Writer
)

func init() {
	if f, err := os.Open("in.goC"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

func main() {
	defer w.Flush()
	var n int
	for I(&n) == nil {
		solve(n)
	}
}

func solve(n int) {
	var s string
	for i := 0; i < n; i++ {
		I(&s)
		if s[0] == 'R' && s[1] > '0' && s[1] <= '9' && strings.Contains(s, "C") {
			ss := strings.Split(s, "C")
			col, row := ss[1], ss[0][1:]
			O(base26(col) + row + "\n")
		} else {
			f := sort.Search(len(s), func(z int) bool { return s[z] < 'A' })
			col, row := s[:f], s[f:]
			O("R" + row + "C" + base10(col) + "\n")
		}
	}
}

func base10(s string) string {
	ss := uint64(0)
	o := uint64(1)
	for i := len(s) - 1; i >= 0; i-- {
		ss += uint64(s[i]-'A'+1) * o
		o *= 26
	}
	return strconv.FormatUint(ss, 10)
}

func base26(s string) string {
	ss, _ := strconv.ParseUint(s, 10, 64)
	sss := ""
	for ss > 0 {
		o := 'A' - 1 + (ss % 26)
		if ss%26 == 0 {
			o += 26
			ss--
		}
		sss = string(o) + sss
		ss /= 26
	}
	return sss
}

package main
import (
    "fmt"
    "strconv")

func isDigit(c byte) bool {
    return c>='0' && c<='9'
}

func parse(s string) int {
    var c int = 0
    var lastDigit bool = false
    data := []string{"", "", "", ""}
    var form int
    //dumpData(data)
    for i:=0; i<len(s); i++{
        digit := isDigit(s[i])
        if digit {
            if lastDigit {
                data[c] = data[c] + string(s[i])
            } else {
                c++
                data[c] = data[c] + string(s[i])
            }
        } else {
            if lastDigit {
                c++
                data[c] = data[c] + string(s[i])
            } else {
                data[c] = data[c] + string(s[i])
            }

        }
        lastDigit = digit
        //
    }
    //dumpData(data)

    if data[2] == "" {
        form = 2
        r, _ := strconv.ParseInt(data[1], 10, 64)
        c := int64(azToInt(data[0]))
        fmt.Printf("R%dC%d\n", r, c)
    } else {
        form = 1

        r, _ := strconv.ParseInt(data[3], 10, 64)
        x := intToAz(r)
        y := data[1]
        fmt.Printf("%s%s\n", x, y)
    }
    return form
}

func azToInt(az string) int64 {
    var res int64 = 0
    for n := 0; n<len(az); n++ {
        t := charTo26(az[n])
        res = 26*res + t
    }
    return res
}

func charTo26(char byte) int64 {
    return int64(1 + char - byte('A'))
}

func intTo26(n int64) string {
    if n==0 {
        return ""
    } else {
        return string(byte(n) + byte('A')-1)
    }
}

func intToAz(n int64) string {
    var res string = ""
    var d int64 = n
    for ;d!=0; {
        dd := d % 26
        ddd := d / 26
        if dd != 0 {
            res = intTo26(dd) + res
        } else {
            res = intTo26(26) + res
            ddd = ddd - 1
        }
        d = ddd
    }
    return res
}

func main() {
    var s string
    var i, c int64
    fmt.Scanf("%d", &c)
    for i=1; i<=c; i++ {
        fmt.Scanf("\n%s", &s)
        parse(s)
    }
}

package main

import (
	"fmt"
	"regexp"
	"strconv"
	"strings"
)

func main() {
	Main()
}

// Main .. ho
func Main() {
	var n int
	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		var str string
		fmt.Scan(&str)
		fmt.Printf("%v\n", Solve1b(str))
	}
}

// Solve1b solution
func Solve1b(str string) string {
	format, row, col := Decode(str)

	//fmt.Printf("Inc: %v %v %v\n", format, row, col)
	if format == RC {
		return EncodeA1(row, col)
	}
	return EncodeRC(row, col)
}

var matcher = regexp.MustCompile(`^R(\d+)C(\d+)$|^([A-Z]+)(\d+)$`)

// Decode ..
func Decode(str string) (Format, int, int) {
	matches := matcher.FindAllStringSubmatch(str, -1)
	if len(matches) != 1 {
		panic("invalid input: " + str)
	}
	match := matches[0]
	if match[1] != "" {
		//fmt.Printf("RC: %v %v", match[1], match[2])
		row, _ := strconv.Atoi(match[1])
		col, _ := strconv.Atoi(match[2])
		return RC, row, col
	}

	//fmt.Printf("match 3: %v", match[3])
	col := convertRow(match[3])
	row, _ := strconv.Atoi(match[4])
	return A1, row, col
}

func EncodeRC(row int, col int) string {
	return "R" + strconv.Itoa(row) + "C" + strconv.Itoa(col)
}

func EncodeA1(row int, col int) string {
	return A1Fmt(col) + strconv.Itoa(row)
}

func A1Fmt(row int) string {
	r := ""
	al := len(ALPHABETH)
	for {
		row -= 1

		ind := row % al
		row = (row - ind) / al

		r = string(ALPHABETH[ind]) + r

		if row == 0 {
			break
		}

		// fmt.Printf("ln: %v %v\n", row, al)
	}
	return r
}

// ..
type Format int

const (
	RC Format = iota
	A1 Format = iota
)

const ALPHABETH = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

func convertRow(alpha string) int {
	s := 0
	for r := 0; r < len(alpha); r++ {
		v := strings.Index(ALPHABETH, string(alpha[r]))
		if v == -1 {
			panic("INVALID INPUT: " + alpha)
		}
		s = s*len(ALPHABETH) + v + 1
	}

	return s
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"regexp"
	"strconv"
	"strings"
)

func main() {
	Main()
}

// Main .. ho
func Main() {
	var n int
	reader := bufio.NewReader(os.Stdin)

	line, _ := reader.ReadString('\n')
	n, _ = strconv.Atoi(strings.TrimSpace(line))

	for i := 0; i < n; i++ {
		str, _ := reader.ReadString('\n')
		fmt.Printf("%v\n", Solve1b(strings.TrimSpace(str)))
	}
}

// Solve1b solution
func Solve1b(str string) string {
	format, row, col := Decode(str)

	//fmt.Printf("Inc: %v %v %v\n", format, row, col)
	if format == RC {
		return EncodeA1(row, col)
	}
	return EncodeRC(row, col)
}

var matcher = regexp.MustCompile(`^R(\d+)C(\d+)$|^([A-Z]+)(\d+)$`)

// Decode ..
func Decode(str string) (Format, int, int) {
	matches := matcher.FindAllStringSubmatch(str, -1)
	if len(matches) != 1 {
		panic("invalid input: " + str)
	}
	match := matches[0]
	if match[1] != "" {
		//fmt.Printf("RC: %v %v", match[1], match[2])
		row, _ := strconv.Atoi(match[1])
		col, _ := strconv.Atoi(match[2])
		return RC, row, col
	}

	//fmt.Printf("match 3: %v", match[3])
	col := convertRow(match[3])
	row, _ := strconv.Atoi(match[4])
	return A1, row, col
}

func EncodeRC(row int, col int) string {
	return "R" + strconv.Itoa(row) + "C" + strconv.Itoa(col)
}

func EncodeA1(row int, col int) string {
	return A1Fmt(col) + strconv.Itoa(row)
}

func A1Fmt(row int) string {
	r := ""
	al := len(ALPHABETH)
	for {
		row -= 1

		ind := row % al
		row = (row - ind) / al

		r = string(ALPHABETH[ind]) + r

		if row == 0 {
			break
		}

		// fmt.Printf("ln: %v %v\n", row, al)
	}
	return r
}

// ..
type Format int

const (
	RC Format = iota
	A1 Format = iota
)

const ALPHABETH = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

func convertRow(alpha string) int {
	s := 0
	for r := 0; r < len(alpha); r++ {
		v := strings.Index(ALPHABETH, string(alpha[r]))
		if v == -1 {
			panic("INVALID INPUT: " + alpha)
		}
		s = s*len(ALPHABETH) + v + 1
	}

	return s
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"regexp"
	"strconv"
	"strings"
)

var n int

// RZ228 - S@228
// R228C494
// 1
// R228C494

// expected: 'AHZ901', found: 'AI@901'

//https://codeforces.com/problemset/status/1/problem/B/page/33?order=BY_PROGRAM_LENGTH_ASC
func main() {
	var inputs = make([]string, 0)

	scanner := bufio.NewScanner(os.Stdin)

	var t string
	for scanner.Scan() {
		t = scanner.Text()
		if t == "" {
			break
		}

		inputs = append(inputs, t)
	}
	n, _ = strconv.Atoi(inputs[0])
	for i := 1; i <= n; i++ {
		solution(inputs[i])
	}
}

func solution(input string) {
	// find numbers
	r := regexp.MustCompile("[0-9]+")
	nsa := r.FindAllString(input, -1)

	if len(nsa) == 1 { // BC23
		str := strings.Split(input, nsa[0])[0]
		columnNumber := fromColumnStringToInt(str)
		fmt.Printf("R%vC%v\n", nsa[0], columnNumber)
	} else { // R23C55
		fmt.Printf("%v%v\n", column2A(stringToInt(nsa[1])), nsa[0])
	}
}

func column2A(n int) (ret string) {
	for n > 0 {
		ret = string('A'+(n+25)%26) + ret
		n = (n - 1) / 26
	}
	return
}

func fromColumnStringToInt(input string) int {
	number, factor := 0, 1

	// factor := 1
	for i := len(input) - 1; i >= 0; i-- {
		number += factor * int(input[i]-'@')
		factor *= 26
	}

	return number
}

func stringToInt(input string) int {
	v, _ := strconv.Atoi(input)
	return v
}

// http://codeforces.com/problemset/problem/1/B

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"regexp"
	"strconv"
)

func main() {
	var n int
	fmt.Scanln(&n)
	var ls []string
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < n; i++ {
		text, _ := reader.ReadString('\n')
		ls = append(ls, text)
	}
	// fmt.Println(ls)
	for _, v := range ls {
		match1, _ := regexp.MatchString(`\b([A-Z]+[0-9]+)\b`, v)
		match2, _ := regexp.MatchString(`\b([R][0-9]+[C][0-9]+)\b`, v)
		if match1 == true {
			c := regexp.MustCompile(`([A-Z]+)`).FindAllString(v, -1)
			r := regexp.MustCompile(`([0-9]+)`).FindAllString(v, 1)
			a := Radix26toDec(c[0])
			ans := "R" + r[0] + "C" + strconv.Itoa(a)
			fmt.Println(ans)
		}
		if match2 == true {
			c1 := regexp.MustCompile(`(\d+)`).FindAllString(v, -1)
			i, _ := strconv.Atoi(c1[1])
			a1 := DectoRadix26(i)
			r1 := c1[0]
			ans1 := a1 + r1
			fmt.Println(ans1)
		}
	}
}

func reverse(s string) string {
	r := ""
	for _, v := range s {
		r = string(v) + r
	}
	return r
}

func DectoRadix26(n int) string {
	z := map[int]string{1: "A", 2: "B", 3: "C", 4: "D", 5: "E", 6: "F", 7: "G", 8: "H", 9: "I", 10: "J", 11: "K", 12: "L", 13: "M", 14: "N", 15: "O", 16: "P", 17: "Q", 18: "R",
		19: "S", 20: "T", 21: "U", 22: "V", 23: "W", 24: "X", 25: "Y", 26: "Z"}
	s := ""
	for n > 0 {
		if n%26 == 0 {
			n = n/26 - 1
			s += "Z"
		} else {
			r := n % 26
			n = n / 26
			s += z[r]
		}
	}
	return reverse(s)
}

func Radix26toDec(n string) int {
	z := map[string]int{"A": 1, "B": 2, "C": 3, "D": 4, "E": 5, "F": 6, "G": 7, "H": 8, "I": 9, "J": 10, "K": 11, "L": 12, "M": 13, "N": 14, "O": 15, "P": 16, "Q": 17, "R": 18,
		"S": 19, "T": 20, "U": 21, "V": 22, "W": 23, "X": 24, "Y": 25, "Z": 26}
	d := 0
	n_r := reverse(n)
	ind := 0.0
	for _, v := range n_r {
		d += z[string(v)] * int(math.Pow(26, ind))
		ind += 1
	}
	return d
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"regexp"
	"strconv"
	"strings"
)

var rowExpRC, _ = regexp.Compile("R[0-9]+")
var colExpRC, _ = regexp.Compile("C[0-9]+")
var rowExp, _ = regexp.Compile("[0-9]+")
var colExp, _ = regexp.Compile("[A-Z]+")

func colNumber2String(number int64) string {
	colBytesReversed := make([]byte, 5)
	var j, k int
	for j = 0; number != 0; j++ {
		if number%26 == 0 {
			colBytesReversed[j] = 'Z'
			number = number/26 - 1
		} else {
			colBytesReversed[j] = byte(64 + (number % 26))
			number = number / 26
		}
	}
	colBytes := make([]byte, j)
	for k = 0; k < j; k++ {
		colBytes[k] = colBytesReversed[j-1-k]
	}
	return string(colBytes)
}

func colString2Number(col string) int64 {
	var mi int64 = 1
	var ret int64 = 0
	colBytes := []byte(col)

	for i := len(colBytes) - 1; i >= 0; i-- {
		ret = ret + (int64(colBytes[i])-64)*mi
		mi = mi * 26
	}
	return ret
}

func main() {
	var n int
	var expr string
	s := bufio.NewScanner(os.Stdin)
	s.Scan()
	n, _ = strconv.Atoi(s.Text())
	for i := 0; i < n; i++ {
		s.Scan()
		expr = s.Text()
		isRC, _ := regexp.MatchString("^R[0-9]+C[0-9]+$", expr)
		if isRC {
			rowString := rowExpRC.FindString(expr)
			colString := colExpRC.FindString(expr)
			rowString = strings.Trim(rowString, "R")
			colString = strings.Trim(colString, "C")
			col, _ := strconv.ParseInt(colString, 10, 64)
			fmt.Printf("%s%s", colNumber2String(col), rowString)
		} else {
			rowString := rowExp.FindString(expr)
			colString := colExp.FindString(expr)
			colNumber := colString2Number(colString)
			fmt.Printf("R%sC%d", rowString, colNumber)
		}
		if i != n-1 {
			fmt.Printf("\n")
		}
	}
}

package main

import (
	"fmt"
	"strings"
	"strconv"
)

const RxCy uint8 = 0;
const AZx uint8 = 1;

func decide(s string) (ret uint8) {
	if s[0] == 'R' {
		if s[1] >= 'A' {
			ret = AZx
		} else {
			for i := 2; i<len(s); i++ {
				if s[i] == 'C' {
					ret = RxCy
					return ret
				}
			}
			ret = AZx
		}
	} else {
		ret = AZx
	}
	return ret
}
func getColumn1(s string) (ret uint) { // from RxCy coding
	var from uint = uint(strings.Index(s, "C")) + 1
	var len uint = uint(len(s))
	tmp, _ := strconv.ParseUint(s[from:len], 10, 64)
	ret = uint(tmp)
	return ret
}
func getRow1(s string) (ret string) { // from RxCy coding
	ret = s[1:strings.Index(s, "C")]
	return ret
}
func Reverse(s string) string {
    r := []rune(s)
    for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
        r[i], r[j] = r[j], r[i]
    }
    return string(r)
}
func convertColumn(c uint) (output string) { // from number to AZx format
	var last byte = '0'
	for c != 0 {
		last = byte('A') + byte((c - 1) % 26)
		output += string([]byte{last})
		c = (c - 1) / 26
	}
	output = Reverse(output)
	return output;
}
func getColumn2(s string) (output uint) { // from AZx coding
	var c byte
	for i:=0; i<len(s); i++ {
		c = s[i]
		if c <= 'Z' && c >= 'A' {
			output = output * 26 + uint(c - 'A' + 1)
		} else {
			break
		}
	}
	return output
}
func getRow2(s string) (ret string) { // from AZx coding
	var from uint = 0
	var c byte
	for from < uint(len(s)) {
		c = s[from];
		if c <= '9' && c >= '0' {
			break
		}
		from++
	}
	return s[from:]
}
func convert1(s string) (output string) { // convert from RxCy to AZx
	output = convertColumn(getColumn1(s))
	return output + getRow1(s)
}
func convert2(s string) (output string) { // convert from AZx to RxCy
	output = "R"
	output += getRow2(s)
	output += "C"
	output += fmt.Sprint(getColumn2(s))
	return output
}

func main() {
	var inputs []string
	var input string
	var count uint
	fmt.Scanf("%d\n", &count)
	var i uint
	for i=0; i<count; i++ {
		fmt.Scanf("%s\n", &input)
		inputs = append(inputs, input)
	}
	for _, elm := range inputs {
		if decide(elm) == RxCy {
			fmt.Println(convert1(elm))
		} else {
			fmt.Println(convert2(elm))
		}
	}
}

package main

import (
	"fmt"
	"os"
	"strings"
	"strconv"
	"regexp"
)

func Reverse(s string) (result string) {
	for _, v := range s {
		result = string(v) + result
	}
	return
}

func intToAZ(a int) string {
	result := ""
	for a > 0 {
		c := a % 26
		a = a / 26
		if c == 0 {
			c = 26
			a -=1
		}

		result += string('A' + c - 1)
	}

	return Reverse(result)
}

func azToInt(s string) int {
	pow := 1
	result := 0
	for i := len(s) - 1; i >= 0; i-- {
		result += pow * int(s[i] - 'A' + 1)
		pow *= 26
	}

	return result
}

var rcRegexp = regexp.MustCompile("R[0-9]+C[0-9]+")

func convert(s string) string {
	if rcRegexp.MatchString(s) {
		var r, c int
		_, err := fmt.Sscanf(s, "R%dC%d", &r, &c)
		if err != nil {
			os.Exit(3)
		}
		return intToAZ(c) + strconv.Itoa(r)
	} else {
		index := strings.IndexFunc(s, func(r rune) bool {
			return r >= '0' && r <= '9'
		})

		var r, c string
		r = s[index:]
		c = strconv.Itoa(azToInt(s[0:index]))

		return fmt.Sprintf("R%sC%s", r, c)
	}
}

func main() {
	var n int
	var ns []string

	_, err := fmt.Scanf("%d\n", &n)
	if err != nil {
		os.Exit(1)
		//log.Fatal(err)
	}

	ns = make([]string, n)

	for i := 0; i < n; i++ {
		_, err := fmt.Scanf("%s\n", &ns[i])
		if err != nil {
			//log.Fatal(err)
			os.Exit(2)
		}
	}

	for i := 0; i < n; i++ {
		fmt.Printf("%s\n", convert(ns[i]))
	}

}

package main

import (
    "fmt"
    "bufio"
    "os"
    "strconv"
)

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    writer := bufio.NewWriter(os.Stdout)
    var n int
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        for scanner.Scan() {
            if scanner.Text() != "" { break }
        }
        s := scanner.Text()
        var ch byte
        found_C := false
        for in, v := range s {
            if v == 'R' { ch = s[in+1] }
            if v == 'C' { found_C = true; break }
        }
        if (ch >= '0') && (ch <= '9') && found_C {
            r, c, in := 0, 0, 1
            for ; s[in] != 'C'; in++ {
                r = (r*10) + int(s[in]-'0')
            }
            for in++; in < len(s); in++ {
                c = (c*10) + int(s[in]-'0')
            }
            col, row := "", strconv.Itoa(r)
            c--
            for c >= 0 {
                a := c%26
                col = string(rune('A'+a)) + col
                if c == 0 {
                    c = -1
                } else {
                    c = (c/26)-1
                }
            }
            writer.WriteString(col+row+"\n")
        } else {
            col, row := 0, ""
            for _, v := range s {
                if (v >= 'A') && (v <= 'Z') {
                    col = (col*26) + int(v-'A'+1)
                } else {
                    row += string(v)
                }
            }
            writer.WriteString("R"+row+"C"+strconv.Itoa(col)+"\n")
        }
    }
    writer.Flush()
}

// https://codeforces.com/problemset/problem/1/B

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"math"
	"os"
	"regexp"
	"strconv"
	"strings"
)

// matching
// ----------------

var letterRegex = regexp.MustCompile(`(\W*)?(?P<col>[A-Z]+)(?P<row>[0-9]+)(\W*)?`)
var rowColRegex = regexp.MustCompile(`(\W*)?R(?P<row>[0-9]+)C(?P<col>[0-9]+)(\W*)?`)

func getMatches(regex *regexp.Regexp, text string) (map[string]string, bool) {
	matches := make(map[string]string)

	match := regex.FindStringSubmatch(text)
	if match == nil {
		return matches, false
	}

	for matchIdx, matchName := range regex.SubexpNames() {
		if len(matchName) > 0 && matchIdx >= 0 && matchIdx < len(match) {
			matches[matchName] = match[matchIdx]
		}
	}

	return matches, true
}

// conversion
// ----------------

func letteredToNum(letteredNumber string) int {
	return charactersToNum([]byte(strings.ToLower(letteredNumber)))
}

func charactersToNum(characters []byte) int {
	if len(characters) == 0 {
		return 0
	}

	next, rest := characters[0], characters[1:]
	placementInt := int(math.Pow(26, float64(len(rest))))
	nextInt := int(next) - int('a') + 1

	return placementInt*nextInt + charactersToNum(rest)
}

func numToLetter(number int) (byte, int) {
	number = number - 1
	quotient := number / 26
	remainder := number % 26
	return byte(remainder + int('a')), quotient
}

func numToLettered(number int) string {
	letters := make([]byte, 0)
	letter, quotient := byte(0), number
	for {
		if quotient <= 0 {
			break
		}
		letter, quotient = numToLetter(quotient)
		letters = append(letters, letter)
	}

	var buffer bytes.Buffer
	for idx := len(letters) - 1; idx >= 0; idx-- {
		buffer.WriteByte(letters[idx])
	}

	return strings.ToUpper(buffer.String())
}

// main
// ----------------

func main() {
	var totalCoordinates int

	_, err := fmt.Scanf("%d", &totalCoordinates)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		line := scanner.Text()
		line = strings.TrimSpace(line)

		if rowColMatches, ok := getMatches(rowColRegex, line); ok {
			numberColumn, _ := strconv.Atoi(rowColMatches["col"])
			fmt.Printf("%s%s\n", numToLettered(numberColumn), rowColMatches["row"])
		} else if letterMatches, ok := getMatches(letterRegex, line); ok {
			letteredColumn := letteredToNum(letterMatches["col"])
			fmt.Printf("R%sC%d\n", letterMatches["row"], letteredColumn)
		} else {
			continue
		}
	}
}

// https://codeforces.com/problemset/problem/1/B

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"math"
	"os"
	"regexp"
	"strconv"
	"strings"
)

// matching
// ----------------

var letterRegex = regexp.MustCompile(`(\W*)?(?P<col>[A-Z]+)(?P<row>[0-9]+)(\W*)?`)
var rowColRegex = regexp.MustCompile(`(\W*)?R(?P<row>[0-9]+)C(?P<col>[0-9]+)(\W*)?`)

func getMatches(regex *regexp.Regexp, text string) (map[string]string, bool) {
	matches := make(map[string]string)

	match := regex.FindStringSubmatch(text)
	if match == nil {
		return matches, false
	}

	for matchIdx, matchName := range regex.SubexpNames() {
		if len(matchName) > 0 && matchIdx >= 0 && matchIdx < len(match) {
			matches[matchName] = match[matchIdx]
		}
	}

	return matches, true
}

// conversion
// ----------------

func letteredToNum(letteredNumber string) int {
	return charactersToNum([]byte(strings.ToLower(letteredNumber)))
}

func charactersToNum(characters []byte) int {
	if len(characters) == 0 {
		return 0
	}

	next, rest := characters[0], characters[1:]
	placementInt := int(math.Pow(26, float64(len(rest))))
	nextInt := int(next) - int('a') + 1

	return placementInt*nextInt + charactersToNum(rest)
}

func numToLetter(number int) (byte, int) {
	quotient := number / 26
	remainder := number % 26
	return byte(remainder + int('a')), quotient
}

func numToLettered(number int) string {
	letters := make([]byte, 0)
	letter, quotient := byte(0), number
	for {
		if quotient <= 0 {
			break
		}
		// num to letter assumes 0-25 range instead of 1-26
		letter, quotient = numToLetter(quotient - 1)
		letters = append(letters, letter)
	}

	var buffer bytes.Buffer
	for idx := len(letters) - 1; idx >= 0; idx-- {
		buffer.WriteByte(letters[idx])
	}

	return strings.ToUpper(buffer.String())
}

// main
// ----------------

func main() {
	var totalCoordinates int

	_, err := fmt.Scanf("%d", &totalCoordinates)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		line := scanner.Text()
		line = strings.TrimSpace(line)

		if rowColMatches, ok := getMatches(rowColRegex, line); ok {
			numberColumn, _ := strconv.Atoi(rowColMatches["col"])
			fmt.Printf("%s%s\n", numToLettered(numberColumn), rowColMatches["row"])
		} else if letterMatches, ok := getMatches(letterRegex, line); ok {
			letteredColumn := letteredToNum(letterMatches["col"])
			fmt.Printf("R%sC%d\n", letterMatches["row"], letteredColumn)
		} else {
			continue
		}
	}
}

package main

import "fmt"
import "log"
import "regexp"

func main() {
	var n int;
	args, err := fmt.Scan(&n);
	if err != nil {
		log.Fatal(err);
	}
	if args != 1 {
		log.Fatal("invalid n: ", args);
	}

	re, err := regexp.Compile("R([0-9]+)C([0-9]+)");
	if err != nil {
		log.Fatal(err);
	}
	re2, err := regexp.Compile("([A-Z]+)([0-9]+)");
	if err != nil {
		log.Fatal(err);
	}

	for i := 0; i < n; i++ {
		var s string;
		args, err = fmt.Scan(&s);
		if err != nil {
			log.Fatal(err);
		}
		if args != 1 {
			log.Fatal("missing string?", args);
		}

		r := re.FindStringSubmatch(s)
		if r == nil {
			r := re2.FindStringSubmatch(s);
			if r == nil {
				log.Fatal("didn't match re2");
			}
			alpha_to_rc(r[1], r[2]);
		} else {
			rc_to_alpha(r[1], r[2]);
		}
	}
}

func alpha_to_rc(scol, srow string) {
	var col rune;

	for _, c := range scol {
		col *= 26;

		col += c - 'A' + 1;
	}
	fmt.Printf("R%sC%d\n", srow, col);
}

func rc_to_alpha(s_row, s_col string) {
	var row, col int;
	fmt.Sscan(s_row, &row);
	fmt.Sscan(s_col, &col);

	fmt.Printf("%s%d\n", col_to_alpha(col, ""), row);
}

func col_to_alpha(col int, s string) string {
	col -= 1

	if col < 26 {
		return s + fmt.Sprintf("%c", 'A' + col);
	}
	if col < 27*26 {
		return col_to_alpha(col / 26, s) + fmt.Sprintf("%c", 'A' + (col % 26));
	}
	if col < 27*26*26 {
		return col_to_alpha(col / 26, s) + fmt.Sprintf("%c", 'A' + (col % 26));
	}
	if col < 27*26*26*26 {
		return col_to_alpha(col / 26, s) + fmt.Sprintf("%c", 'A' + (col % 26));
	}
	if col < 27*26*26*26*26 {
		return col_to_alpha(col / 26, s) + fmt.Sprintf("%c", 'A' + (col % 26));
	}
	return "TOOBIG"
}

package main

import (
  "os"
  "bufio"
  "strings"
  "strconv"
  "fmt"
)

var scanner *bufio.Scanner

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}
func getI() int {
  return int(getI64())
}
func getF() float64 {
  scanner.Scan()
  x, _ := strconv.ParseFloat(scanner.Text(), 64)
  return x
}
func getS() string {
  scanner.Scan()
  return scanner.Text()
}

func main() {
  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  n := getI()
  for i := 0; i < n; i++ {
    s := getS()
    numerical := true
    rPos, cPos := strings.IndexByte(s, 'R'), strings.IndexByte(s, 'C')
    if rPos != 0 || cPos == -1 || cPos-rPos <= 1 {
      numerical = false
    } else {
      for j := rPos+1; j < cPos; j++ {
        ch := s[j]
        if ch < '0' || ch > '9' {
          numerical = false
          break
        }
      }
    }
    if numerical {
      r, _ := strconv.Atoi(s[1:cPos])
      c, _ := strconv.Atoi(s[cPos+1:len(s)])
      x := c
      length := 1
      factor := 26
      for factor < x {
        x -= factor
        length += 1
        factor *= 26
      }
      x--
      chars := make([]byte, length)
      for pos := length-1; pos >= 0; pos-- {
        chars[pos] = 'A'+byte(x%26)
        x /= 26
      }
      writer.WriteString(fmt.Sprintf("%s%d\n", string(chars), r))
    } else {
      pos := 0
      for {
        ch := s[pos]
        if ch >= '0' && ch <= '9' {
          break
        }
        pos++
      }
      r, _ := strconv.Atoi(s[pos:len(s)])
      c := 0
      for j := 0; j < pos; j++ {
        c = 26*c + int(s[j]-'A')+1
      }
      writer.WriteString(fmt.Sprintf("R%dC%d\n", r, c))
    }
  }
}

package main

import (
    "fmt"
    "io"
    "unicode"
)

func process(coordinate string) {
    column := 0
    row := 0

    length := len(coordinate)

    k := 0
    for unicode.IsLetter(rune(coordinate[k])) {
        k += 1
    }
    for unicode.IsNumber(rune(coordinate[k])) {
        k += 1
        if k == length {
            break
        }
    }

    if k == length {
        k = 0
        for unicode.IsLetter(rune(coordinate[k])) {
            column = column * 26 + int(coordinate[k] - 64)
            k += 1
        }
        for k < length {
            row = row * 10 + int(coordinate[k] - 48)
            k += 1
        }

        fmt.Printf("R%dC%d\n", row, column)
    } else {
        k = 1
        for unicode.IsNumber(rune(coordinate[k])) {
            row = row * 10 + int(coordinate[k] - 48)
            k += 1
        }
        k += 1
        for k < length {
            column = column * 10 + int(coordinate[k] - 48)
            k += 1
        }

        s := make([]string, 0)
        for column != 0 {
            r := column % 26
            column = column / 26
            if r == 0 {
                s = append(s, "Z")
                column -= 1
            } else {
                s = append(s, string(r + 64))
            }
        }

        for i := len(s) - 1; i >= 0; i-- {
            fmt.Print(s[i])
        }
        fmt.Println(row)
    }
}

func main() {
    var testCases int

    var coordinate string

    for {
        _, err := fmt.Scan(&testCases)
        if err == io.EOF {
            break
        }
        for i := 0; i < testCases; i++ {
            fmt.Scan(&coordinate)
            process(coordinate)
        }
    }
}

package main

import (
    "fmt"
    "io"
    "unicode"
)

func process(coordinate string) {
    column := 0
    row := 0

    length := len(coordinate)

    k := 0
    for unicode.IsLetter(rune(coordinate[k])) {
        k += 1
    }
    for unicode.IsNumber(rune(coordinate[k])) {
        k += 1
        if k == length {
            break
        }
    }

    if k == length {
        k = 0
        for unicode.IsLetter(rune(coordinate[k])) {
            column = column * 26 + int(coordinate[k] - 64)
            k += 1
        }
        for k < length {
            row = row * 10 + int(coordinate[k] - 48)
            k += 1
        }

        fmt.Printf("R%dC%d\n", row, column)
    } else {
        k = 1
        for unicode.IsNumber(rune(coordinate[k])) {
            row = row * 10 + int(coordinate[k] - 48)
            k += 1
        }
        k += 1
        for k < length {
            column = column * 10 + int(coordinate[k] - 48)
            k += 1
        }

        s := make([]string, 0, 5)
        for column != 0 {
            r := column % 26
            column = column / 26
            if r == 0 {
                s = append(s, "Z")
                column -= 1
            } else {
                s = append(s, string(r + 64))
            }
        }

        for i := len(s) - 1; i >= 0; i-- {
            fmt.Print(s[i])
        }
        fmt.Println(row)
    }
}

func main() {
    var testCases int

    var coordinate string

    for {
        _, err := fmt.Scan(&testCases)
        if err == io.EOF {
            break
        }
        for i := 0; i < testCases; i++ {
            fmt.Scan(&coordinate)
            process(coordinate)
        }
    }
}

package main

import (
    "fmt"
    "io"
    "unicode"
)

func process(coordinate string) {
    column := 0
    row := 0

    length := len(coordinate)

    k := 1
    if rune(coordinate[0]) == 'R' && !unicode.IsLetter(rune(coordinate[1])) {
        for k < length && unicode.IsNumber(rune(coordinate[k])) {
            k += 1
        }
    }

    if k == 1 || k == length {
        k = 0
        for unicode.IsLetter(rune(coordinate[k])) {
            column = column * 26 + int(coordinate[k] - 64)
            k += 1
        }
        for k < length {
            row = row * 10 + int(coordinate[k] - 48)
            k += 1
        }

        fmt.Printf("R%dC%d\n", row, column)
    } else {
        k = 1
        for unicode.IsNumber(rune(coordinate[k])) {
            row = row * 10 + int(coordinate[k] - 48)
            k += 1
        }
        k += 1
        for k < length {
            column = column * 10 + int(coordinate[k] - 48)
            k += 1
        }

        s := make([]string, 0)

        var r int
        for column != 0 {
            r = column % 26
            column = column / 26
            if r == 0 {
                s = append(s, "Z")
                column -= 1
            } else {
                s = append(s, string(r + 64))
            }
        }

        for i := len(s) - 1; i >= 0; i-- {
            fmt.Print(s[i])
        }
        fmt.Println(row)
    }
}

func main() {
    var testCases int

    var coordinate string

    for {
        _, err := fmt.Scan(&testCases)
        if err == io.EOF {
            break
        }
        for i := 0; i < testCases; i++ {
            fmt.Scan(&coordinate)
            process(coordinate)
        }
    }
}

package main

import (
    "fmt"
    "io"
    "unicode"
)

func process(coordinate string) {
    column := 0
    row := 0

    length := len(coordinate)

    k := 0
    for unicode.IsLetter(rune(coordinate[k])) {
        k += 1
    }
    for unicode.IsNumber(rune(coordinate[k])) {
        k += 1
        if k == length {
            break
        }
    }

    if k == length {
        k = 0
        for unicode.IsLetter(rune(coordinate[k])) {
            column = column * 26 + int(coordinate[k] - 64)
            k += 1
        }
        for k < length {
            row = row * 10 + int(coordinate[k] - 48)
            k += 1
        }

        fmt.Printf("R%dC%d\n", row, column)
    } else {
        k = 1
        for unicode.IsNumber(rune(coordinate[k])) {
            row = row * 10 + int(coordinate[k] - 48)
            k += 1
        }
        k += 1
        for k < length {
            column = column * 10 + int(coordinate[k] - 48)
            k += 1
        }

        s := make([]string, 0)
        for column != 0 {
            r := column % 26
            if r == 0 {
                s = append(s, "Z")
                column = column / 26 - 1
            } else {
                s = append(s, string(r + 64))
                column = column / 26
            }
        }

        for i := len(s) - 1; i >= 0; i-- {
            fmt.Print(s[i])
        }
        fmt.Println(row)
    }
}

func main() {
    var testCases int

    var coordinate string

    for {
        _, err := fmt.Scan(&testCases)
        if err == io.EOF {
            break
        }
        for i := 0; i < testCases; i++ {
            fmt.Scan(&coordinate)
            process(coordinate)
        }
    }
}

package main

import (
	"bytes"
	"fmt"
	"strconv"
)

func rc2bc(r, c int) {
	var bc int
	var buffer bytes.Buffer

	for c > 26 {
		bc = (c - 1) % 26
		c = (c - 1) / 26
		b := byte('A' + bc)
		buffer.WriteByte(b)
	}
	if c != 0 {
		bc = (c - 1) % 26
		b := byte('A' + bc)
		buffer.WriteByte(b)
	}
	str := buffer.String()
	l := len(str)
	for i := 0; i < l; i++ {
		fmt.Printf("%c", str[l-1-i])
	}
	fmt.Printf("%d\n", r)
}

func bc2rc(r int, bc string) {
	fmt.Printf("%c%d", 'R', r)

	c := 0
	l := len(bc)

	for i, p := 0, 1; i < l; i, p = i+1, p*26 {
		c += int(bc[l-1-i]-'A'+1) * p
	}
	fmt.Printf("%c%d\n", 'C', c)
}

func main() {
	var n int
	var input, bc string
	var rc_system bool
	var r, c int

	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%s\n", &input)

		rc_system = false
		if input[0] == 'R' && input[1] <= '9' && input[1] >= '0' {
			for j := 2; j < len(input)-1; j++ {
				if input[j] == 'C' {
					rc_system = true
					r, _ = strconv.Atoi(input[1:j])
					c, _ = strconv.Atoi(input[j+1:])
					break
				}
			}
		}
		if !rc_system {
			for j := 1; j < len(input); j++ {
				if input[j] <= '9' && input[j] >= '0' {
					r, _ = strconv.Atoi(input[j:])
					bc = input[0:j]
					break
				}
			}
		}

		if rc_system {
			rc2bc(r, c)
			//fmt.Printf("%v:%d,%d\n", rc_system, r, c)
		} else {
			bc2rc(r, bc)
			//fmt.Printf("%v:%d,%s\n", rc_system, r, bc)
		}

	}
}

package main

import "fmt"
import "os"
import "bufio"
import "strconv"
import "regexp"

// convert from RxCy to <col><row> letter number system
func convertToCoord(row string, col string) string {
	cInt, _ := strconv.Atoi(col)
	return toBase26(cInt) + row
}

// convert from <col><row> letter number system to RxCy system
func convertToRC(column string, row string) string {
	return "R" + row + "C" + fromBase26(column)
}

// convert a number like 75 to base 26 using A-Z as characters
func toBase26(num int) string {
	ans := ""
	for num != 0 {
		rem := (num - 1) % 26
		num = (num - 1) / 26
		ans = string('A'+rem) + ans
	}
	return ans
}

func fromBase26(str string) string {
	v := 0
	multiplicand := 1
	for idx := len(str) - 1; idx >= 0; idx-- {
		temp := int(str[idx] - 'A' + 1)
		v += (temp * multiplicand)
		multiplicand *= 26
	}
	return strconv.Itoa(v)
}

func main() {
	rcRegexp := regexp.MustCompile(`^R(?P<Row>[[:digit:]]+)C(?P<Column>[[:digit:]]+)$`)
	coordRegexp := regexp.MustCompile(`^(?P<Column>[[:upper:]]+)(?P<Row>[[:digit:]]+)$`)

	s := bufio.NewScanner(os.Stdin)
	s.Scan()
	val, _ := strconv.Atoi(s.Text())
	//fmt.Println("Reading", val, "values")

	for i := 0; i < val; i++ {
		s.Scan()
		coord := s.Text()

		isRc := rcRegexp.FindStringSubmatch(coord)
		isCoord := coordRegexp.FindStringSubmatch(coord)

		if len(isRc) > 0 {
			fmt.Println(convertToCoord(isRc[1], isRc[2]))
		} else if len(isCoord) > 0 {
			fmt.Println(convertToRC(isCoord[1], isCoord[2]))
		}
	}
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
	"regexp"
	"strconv"
	"strings"
)

var AZtoY = map[string]int{}

func concatString(a, b string) string {
	bs := make([]byte, len(a)+len(b))
	bl := 0
	bl += copy(bs[bl:], a)
	copy(bs[bl:], b)
	return string(bs)
}

func isRXCY(coor string) bool {
	match, _ := regexp.MatchString("^R[0-9]+C", coor)
	return match
}

func YtoAZ(y int) string {
	var col string
	for y > 0 {
		if y%26 == 0 {
			y = y/26 - 1
			col = concatString("Z", col)
			continue
		}
		col = concatString(string(rune(64+y%26)), col)
		y = y / 26
	}
	return col

	// Recursion version
	// if y%26 == 0 {
	// 	y = y/26 - 1
	// 	return YtoAZ(y) + "Z"
	// } else if y < 26 {
	// 	return string(rune(64 + y))
	// }
	// return YtoAZ(y/26) + YtoAZ(y%26)
}

func RXCYtoExcel(coor string) string {
	cIndex := strings.Index(coor, "C")
	x := coor[1:cIndex]
	y, _ := strconv.Atoi(coor[cIndex+1:])

	return concatString(YtoAZ(y), x)
}

func ExceltoRXCY(coor string) string {
	index := regexp.MustCompile(`[0-9]`).FindIndex([]byte(coor))
	col := coor[:index[0]]
	row := coor[index[0]:]

	rx := concatString("R", row)

	var y int
	pow := 1
	for i := len(col); i > 0; i-- {
		y = y + AZtoY[col[i-1:i]]*pow
		pow = pow * 26
	}

	cy := concatString("C", strconv.Itoa(y))
	return rx + cy
}

func main() {
	for i := 1; i <= 26; i++ {
		AZtoY[string(rune(64+i))] = i
	}
	lineReader := bufio.NewReader(os.Stdin)
	input, _ := lineReader.ReadString('\n')
	drop := 1
	if input[len(input)-2] == '\r' {
		drop = 2
	}
	n, _ := strconv.Atoi(input[0 : len(input)-drop])

	var output bytes.Buffer

	for i := 0; i < n; i++ {
		input, _ := lineReader.ReadString('\n')
		drop := 1
		if input[len(input)-2] == '\r' {
			drop = 2
		}
		input = input[0 : len(input)-drop]
		if isRXCY(input) {
			output.WriteString(RXCYtoExcel(input))
		} else {
			output.WriteString(ExceltoRXCY(input))
		}
		output.WriteByte('\n')
	}
	fmt.Print(output.String())
}

package main

import (
	"fmt"
	"strconv"
)

func main() {
	var cases int64
	fmt.Scan(&cases)
	for i := int64(0); i < cases; i++ {
		var str string
		fmt.Scan(&str)
		intstr := ""
		isAnother := false
		columns, rows := "", ""
		for i := len(str) - 1; i >= 0; i-- {
			if str[i] >= '0' && str[i] <= '9' {
				intstr = str[i:i+1] + intstr
				continue
			}
			if str[i] == 'C' {
				if str[0] == 'R' && str[1] >= '0' && str[1] <= '9' && i > 1 {
					isAnother = true
					columns = intstr
					rows = str[1:i]
					break
				}
			}
			rows = intstr
			columns = str[0:i+1]
			break
		}
		// fmt.Println(rows, columns, intstr)
		if isAnother { // R23C55 --> BC23
			columns = intConvertAZ(columns)
			fmt.Println(columns + rows)
		} else { // BC23 --> R23C55
			columns = AZConvertInt(columns)
			fmt.Println("R" + rows + "C" + columns)
		}
	}
}

func intConvertAZ(str string) string {
	number := 0
	for i := 0; i < len(str); i++ {
		number = number*10 + int(str[i]-'0')
	}
	result := ""
	// fmt.Println(number)
	for number >= 26 {
		left := number % 26
		number = number / 26
		char := 0
		if left == 0 {
			char = 'Z'
			number--
		} else {
			char = 'A' + left - 1
		}
		// fmt.Println(left, number, char)
		result = string(char) + result
	}
	if number > 0 { // 55 = 26 * 2 + 3
		char := 'A' + byte(number - 1)
		// fmt.Println(result)
		result = string([]byte{char}) + result
		// fmt.Println(char, result)
	}
	// fmt.Println(str, result)
	return result
}

func AZConvertInt(str string) string {
	number := 0
	for i := 0; i < len(str); i++ {
		temp := str[i] - 'A' + 1
		number = number*26 + int(temp)
	}
	// fmt.Println(str, number)
	return strconv.Itoa(number)
}

package main

import (
	"fmt"
	"math"
	"regexp"
	"strconv"
)

func toPattern1(row int, col int) string {
	return fmt.Sprintf("R%dC%d", row, col)
}

func toPattern2(row int, col int) string {
	colString := ""
	for col > 0 {
		colString = string('A'+byte(col%26)-1) + colString
		col /= 26
	}
	return fmt.Sprintf("%s%d", colString, row)
}

func main() {
	var n int

	fmt.Scanf("%d", &n)

	var cellName string
	pattern1, _ := regexp.Compile("R([0-9]+)C([0-9]+)")
	pattern2, _ := regexp.Compile("([A-Z]+)([0-9]+)")
	var row, col int

	for i := 0; i < n; i++ {
		fmt.Printf("%d", i)
		fmt.Scanf("%s", &cellName)
		results := pattern1.FindStringSubmatch(cellName)
		if results != nil {
			row, _ = strconv.Atoi(results[1])
			col, _ = strconv.Atoi(results[2])
			fmt.Println(toPattern2(row, col))
			continue
		}

		results = pattern2.FindStringSubmatch(cellName)
		if results != nil {
			row, _ = strconv.Atoi(results[2])
			chars := []byte(results[1])
			counter := 0
			col = 0
			for j := len(chars) - 1; j >= 0; j-- {
				digit := float64(chars[j] - 'A' + 1)
				col += int(digit * math.Pow(26, float64(counter)))
				counter += 1
			}
			fmt.Println(toPattern1(row, col))
			continue
		}
	}
}

package main

import (
	"fmt"
	"math"
	"regexp"
	"strconv"
)

func toPattern1(row int, col int) string {
	return fmt.Sprintf("R%dC%d", row, col)
}

func toPattern2(row int, col int) string {
	colString := ""
	for col > 0 {
		colString = string('A'+byte(col%26)-1) + colString
		col /= 26
	}
	return fmt.Sprintf("%s%d", colString, row)
}

func main() {
	var n int

	fmt.Scanf("%d", &n)

	var cellName string
	pattern1, _ := regexp.Compile("R([0-9]+)C([0-9]+)")
	pattern2, _ := regexp.Compile("([A-Z]+)([0-9]+)")
	var row, col int

	for i := 0; i < n; i++ {
		fmt.Scanf("%s", &cellName)
		results := pattern1.FindStringSubmatch(cellName)
		if results != nil {
			row, _ = strconv.Atoi(results[1])
			col, _ = strconv.Atoi(results[2])
			fmt.Println(toPattern2(row, col))
			continue
		}

		results = pattern2.FindStringSubmatch(cellName)
		if results != nil {
			row, _ = strconv.Atoi(results[2])
			chars := []byte(results[1])
			counter := 0
			for i = len(chars) - 1; i >= 0; i-- {
				digit := float64(chars[i] - 'A' + 1)
				col += int(digit * math.Pow(26, float64(counter)))
				counter += 1
			}
			fmt.Println(toPattern1(row, col))
			continue
		}
	}
}

package main

import (
	"fmt"
	"math"
	"regexp"
	"strconv"
)

func toPattern1(row int, col int) string {
	return fmt.Sprintf("R%dC%d", row, col)
}

func toPattern2(row int, col int) string {
	colString := ""
	for col > 0 {
		colString = string('A'+byte(col%26)-1) + colString
		col /= 26
	}
	return fmt.Sprintf("%s%d", colString, row)
}

func main() {
	var n int

	fmt.Scanf("%d", &n)

	var cellName string
	pattern1, _ := regexp.Compile("R([0-9]+)C([0-9]+)")
	pattern2, _ := regexp.Compile("([A-Z]+)([0-9]+)")
	var row, col int

	for i := 0; i < n; i++ {
		fmt.Scanf("%s", &cellName)
		results := pattern1.FindStringSubmatch(cellName)
		if results != nil {
			row, _ = strconv.Atoi(results[1])
			col, _ = strconv.Atoi(results[2])
			fmt.Println(toPattern2(row, col))
			continue
		}

		results = pattern2.FindStringSubmatch(cellName)
		if results != nil {
			row, _ = strconv.Atoi(results[2])
			chars := []byte(results[1])
			counter := 0
			col = 0
			for j := len(chars) - 1; j >= 0; j-- {
				digit := float64(chars[j] - 'A' + 1)
				col += int(digit * math.Pow(26, float64(counter)))
				counter += 1
			}
			fmt.Println(toPattern1(row, col))
			continue
		}
	}
}

package main

import (
	"fmt"
	"math"
	"regexp"
	"strconv"
)

func toPattern1(row int, col int) string {
	return fmt.Sprintf("R%dC%d", row, col)
}

func toPattern2(row int, col int) string {
	colString := ""
	for col > 0 {
		colString = string('A'+byte(col%26)-1) + colString
		col /= 26
	}
	return fmt.Sprintf("%s%d", colString, row)
}

func main() {
	var n int

	fmt.Scanf("%d", &n)

	var cellName string
	pattern1, _ := regexp.Compile("R([0-9]+)C([0-9]+)")
	pattern2, _ := regexp.Compile("([A-Z]+)([0-9]+)")
	var row, col int

	for i := 0; i < n; i++ {
		fmt.Scanf("%s", &cellName)
		results := pattern1.FindStringSubmatch(cellName)
		if results != nil {
			row, _ = strconv.Atoi(results[1])
			col, _ = strconv.Atoi(results[2])
			fmt.Println(toPattern2(row, col))
			continue
		}

		results = pattern2.FindStringSubmatch(cellName)
		if results != nil {
			row, _ = strconv.Atoi(results[2])
			chars := []byte(results[1])
			counter := 0
			for i := len(chars) - 1; i >= 0; i-- {
				digit := float64(chars[i] - 'A' + 1)
				col += int(digit * math.Pow(26, float64(counter)))
				counter += 1
			}
			fmt.Println(toPattern1(row, col))
			continue
		}
	}
}

package main

import (
	"fmt"
	"math"
	"regexp"
	"strconv"
)

func toPattern1(row int, col int) string {
	return fmt.Sprintf("R%dC%d", row, col)
}

func toPattern2(row int, col int) string {
	colString := ""
	for col > 0 {
		colString = string('A'+byte(col%26)-1) + colString
		col /= 26
	}
	return fmt.Sprintf("%s%d", colString, row)
}

func main() {
	var n int

	fmt.Scanf("%d", &n)

	var cellName string
	pattern1, _ := regexp.Compile("R([0-9]+)C([0-9]+)")
	pattern2, _ := regexp.Compile("([A-Z]+)([0-9]+)")
	var row, col int

	for i := 0; i < n; {
		fmt.Scanf("%s", &cellName)
		results := pattern1.FindStringSubmatch(cellName)
		if results != nil {
			row, _ = strconv.Atoi(results[1])
			col, _ = strconv.Atoi(results[2])
			fmt.Println(toPattern2(row, col))
			i++
			continue
		}

		results = pattern2.FindStringSubmatch(cellName)
		if results != nil {
			row, _ = strconv.Atoi(results[2])
			chars := []byte(results[1])
			counter := 0
			col = 0
			for j := len(chars) - 1; j >= 0; j-- {
				digit := float64(chars[j] - 'A' + 1)
				col += int(digit * math.Pow(26, float64(counter)))
				counter += 1
			}
			fmt.Println(toPattern1(row, col))
			i++
			continue
		}
	}
}

package main

import (
	"fmt"
	"math"
	"regexp"
	"strconv"
)

func toPattern1(row int, col int) string {
	return fmt.Sprintf("R%dC%d", row, col)
}

func toPattern2(row int, col int) string {
	colString := ""
	for col > 0 {
		colString = string('A'+byte(col%26)-1) + colString
		col /= 26
	}
	return fmt.Sprintf("%s%d", colString, row)
}

func main() {
	var n int

	fmt.Scanf("%d", &n)

	var cellName string
	pattern1, _ := regexp.Compile("R([0-9]+)C([0-9]+)")
	pattern2, _ := regexp.Compile("([A-Z]+)([0-9]+)")
	var row, col int

	for i := 0; i < n; i++ {
		fmt.Scanf("%s", &cellName)
		results := pattern1.FindStringSubmatch(cellName)
		if results != nil {
			row, _ = strconv.Atoi(results[1])
			col, _ = strconv.Atoi(results[2])
			fmt.Println(toPattern2(row, col))
			continue
		}

		results = pattern2.FindStringSubmatch(cellName)
		if results != nil {
			row, _ = strconv.Atoi(results[2])
			chars := []byte(results[1])
			counter := 0
			col = 0
			for j := len(chars) - 1; j >= 0; j-- {
				digit := float64(chars[j] - 'A' + 1)
				col += int(digit * math.Pow(26, float64(counter)))
				counter += 1
			}
			fmt.Println(toPattern1(row, col))
			continue
		}
		fmt.Println("Invalid cell name: " + cellName)
		fmt.Println(results)
	}
}

package main

import (
	"fmt"
	"math"
	"regexp"
	"strconv"
)

func toPattern1(row int, col int) string {
	return fmt.Sprintf("R%dC%d", row, col)
}

func toPattern2(row int, col int) string {
	colString := ""
	for col > 0 {
		colString = string('A'+byte(col%26)-1) + colString
		col /= 26
	}
	return fmt.Sprintf("%s%d", colString, row)
}

func main() {
	var n int

	fmt.Scanf("%d", &n)

	var cellName string
	pattern1, _ := regexp.Compile("R([0-9]+)C([0-9]+)")
	pattern2, _ := regexp.Compile("([A-Z]+)([0-9]+)")
	var row, col int

	for i := 0; i < n; {
		fmt.Scanf("%s", &cellName)
		fmt.Println(cellName)
		results := pattern1.FindStringSubmatch(cellName)
		if results != nil {
			row, _ = strconv.Atoi(results[1])
			col, _ = strconv.Atoi(results[2])
			fmt.Println(toPattern2(row, col))
			i++
			continue
		}

		results = pattern2.FindStringSubmatch(cellName)
		if results != nil {
			row, _ = strconv.Atoi(results[2])
			chars := []byte(results[1])
			counter := 0
			col = 0
			for j := len(chars) - 1; j >= 0; j-- {
				digit := float64(chars[j] - 'A' + 1)
				col += int(digit * math.Pow(26, float64(counter)))
				counter += 1
			}
			fmt.Println(toPattern1(row, col))
			i++
			continue
		}
	}
}

package main

import (
	"fmt"
	"math"
	"regexp"
	"strconv"
)

func toPattern1(row int, col int) string {
	return fmt.Sprintf("R%dC%d", row, col)
}

func toPattern2(row int, col int) string {
	colString := ""
	for col > 0 {
		colString = string('A'+byte(col%26)-1) + colString
		col /= 26
	}
	return fmt.Sprintf("%s%d", colString, row)
}

func main() {
	var n int

	fmt.Scanf("%d", &n)

	var cellName string
	pattern1, _ := regexp.Compile("R([0-9]+)C([0-9]+)")
	pattern2, _ := regexp.Compile("([A-Z]+)([0-9]+)")
	var row, col int

	for i := 0; i < n; i++ {
		fmt.Scanf("%s", &cellName)
		results := pattern1.FindStringSubmatch(cellName)
		if results != nil {
			row, _ = strconv.Atoi(results[1])
			col, _ = strconv.Atoi(results[2])
			fmt.Print(toPattern2(row, col))
			continue
		}

		results = pattern2.FindStringSubmatch(cellName)
		if results != nil {
			row, _ = strconv.Atoi(results[2])
			chars := []byte(results[1])
			counter := 0
			for i = len(chars) - 1; i >= 0; i-- {
				digit := float64(chars[i] - 'A' + 1)
				col += int(digit * math.Pow(26, float64(counter)))
				counter += 1
			}
			fmt.Print(toPattern1(row, col))
			continue
		}
	}
}

package main

import (
	"fmt"
	"math"
	"regexp"
	"strconv"
)

func toPattern1(row int, col int) string {
	return fmt.Sprintf("R%dC%d", row, col)
}

func toPattern2(row int, col int) string {
	colString := ""
	for col > 0 {
		colString = string('A'+byte(col%26)-1) + colString
		col /= 26
	}
	return fmt.Sprintf("%s%d", colString, row)
}

func main() {
	var n int

	fmt.Scanf("%d", &n)

	pattern1, _ := regexp.Compile("R([0-9]+)C([0-9]+)")
	pattern2, _ := regexp.Compile("([A-Z]+)([0-9]+)")
	var row, col int

	for i := 0; i < n; {
		var cellName string
		fmt.Scanf("%s", &cellName)
		results := pattern1.FindStringSubmatch(cellName)
		if results != nil {
			row, _ = strconv.Atoi(results[1])
			col, _ = strconv.Atoi(results[2])
			fmt.Println(toPattern2(row, col))
			i++
			continue
		}

		results = pattern2.FindStringSubmatch(cellName)
		if results != nil {
			row, _ = strconv.Atoi(results[2])
			chars := []byte(results[1])
			counter := 0
			col = 0
			for j := len(chars) - 1; j >= 0; j-- {
				digit := float64(chars[j] - 'A' + 1)
				col += int(digit * math.Pow(26, float64(counter)))
				counter += 1
			}
			fmt.Println(toPattern1(row, col))
			i++
			continue
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
	"sync"
	"unicode"
)

const (
	maxn = int(1e5 + 50)
	mod  = int(1e9 + 7)
	eps  = 1e-8
	inf  = int(0x3f3f3f3f)
)

func main() {
	var T int
	scanInt(&T)
	for kase := 1; kase <= T; kase++ {
		s := scanString()
		t := 0
		tag := -1
		flag := false
		for i, x := range s {
			if !flag && unicode.IsDigit(x) {
				flag = true
				tag = i
			} else if flag && !unicode.IsDigit(x) {
				t = 1
				tag = i
				break
			}
		}
		if t == 0 {
			C := int64(0)
			for i := 0; i < tag; i++ {
				C = C * 26 + int64(s[i] - 'A' + 1)
			}
			putchar('R')
			printRuneSlice([]rune(s[tag:]), false)
			putchar('C')
			printlnInt64s(C)
		} else {
			C := int64(0)
			flag = false
			for i := tag + 1; i < len(s); i++ {
				C = C * 10 + int64(s[i] - '0')
			}
			var res []rune
			for C >= 26 {
				if C % 26 == 0 {
					res = append(res, 'Z')
				} else {
					res = append(res, rune('A' + C % 26 - 1))
				}
				C /= 26
			}
			if C > 0 {
				res = append(res, rune('A' + C - 1))
			}
			reverse(&res, 0, len(res))
			printRuneSlice(res, false)
			printRuneSlice([]rune(s[1:tag]), true)
		}
 	}
	close(channelType)
	oWg.Wait()
	out.Flush()
}

/*********************** I/O ***********************/

var channelType chan string
var in *bufio.Scanner
var out = bufio.NewWriter(os.Stdout)
var oWg *sync.WaitGroup

// string and slice are the return value
func init() {
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)
	channelType = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)
	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

		for line := range channelType {
			writer.WriteString(line + "\n")
		}
	}()
}
func scanString() string { in.Scan(); return in.Text() }
func scanInt(a *int)     { *a, _ = strconv.Atoi(scanString()) }
func scanInts(a ...*int) {
	for i := range a {
		*a[i], _ = strconv.Atoi(scanString())
	}
}
func scanInt64(a *int64) { *a, _ = strconv.ParseInt(scanString(), 10, 64) }
func scanInt64s(a ...*int64) {
	for i := range a {
		*a[i], _ = strconv.ParseInt(scanString(), 10, 64)
	}
}
func scanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = scanString()
	}
	return s
}
func scanIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		scanInt(&arr[i])
	}
	return arr
}
func scanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		scanInt64(&arr[i])
	}
	return arr
}
func printlnInts(args ...int) {
	for _, x := range args {
		fmt.Fprint(out, x, " ")
	}
	fmt.Fprintln(out)
}
func printlnInt64s(args ...int64) {
	for _, x := range args {
		fmt.Fprint(out, x, " ")
	}
	fmt.Fprintln(out)
}
func printIntSlice(a []int, flag bool) {
	for _, x := range a {
		fmt.Fprint(out, x, " ")
	}
	if flag { fmt.Fprintln(out) }
}
func printRuneSlice(a []rune, flag bool) {
	for _, x := range a {
		fmt.Fprintf(out, "%c", x)
	}
	if flag { fmt.Fprintln(out) }
}
func printInt64Slice(a []int64, flag bool) {
	for _, x := range a {
		fmt.Fprint(out, x, " ")
	}
	if flag { fmt.Fprintln(out) }
}
func putchar(a ...rune) {
	for _, x := range a {
		fmt.Fprintf(out, "%c", x)
	}
}
func printString(s string) { fmt.Fprintln(out, s) }

/*********************** Utils ***********************/

func stringEquivalent(v interface{}) string { return fmt.Sprintf("%v", v) }
func spaceSeperatedStringFromArray(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}
func spaceSeperatedStringFromArray64(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
	}
	return sb.String()
}
func minMaxFromArray(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func minElementFromArray(args ...int64) int64 { mn, _ := minMaxFromArray(args...); return mn }
func maxElementFromArray(args ...int64) int64 { _, mx := minMaxFromArray(args...); return mx }
func lcmCalculation(a, b int64) int64         { return a / gcdCalculation(a, b) * b }
func gcdCalculation(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return gcdCalculation(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func absoluteValue(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}
func min(args ...int) int { mn, _ := minMaxFinder(args...); return mn }
func max(args ...int) int { _, mx := minMaxFinder(args...); return mx }
func minMaxFinder(args ...int) (int, int) {
	minVal, maxVal := int(math.MaxInt32), int(math.MinInt32)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func same(x, y double) bool { return math.Abs(float64(x-y)) < eps }
func popcount(x int) (res int) {
	for i := 0; i < 32; i++ {
		if 1 == (1 & (x >> uint(i))) {
			res++
		}
	}
	return
}
func qp(a, n int64) (res int64) {
	for ; n > 0; n >>= 1 {
		if (n & 1) == 1 {
			res = res * a % int64(mod)
		}
		a = a * a % int64(mod)
	}
	return
}
func divUp(a, b int64) int64 {
	if a % b == 0 { return a / b } else { return a / b + 1 }
}
// [l, r)
func reverse(a *[]rune, l, r int) {
	for i, j := l, r - 1; i < j; i, j = i + 1, j - 1 {
		(*a)[i], (*a)[j] = (*a)[j], (*a)[i]
	}
}

/*********************** Structs ***********************/
type pair struct{ X, Y int }
type double float64
type pairSlice []pair

func (p pairSlice) Len() int { return len(p) }
func (p pairSlice) Less(i, j int) bool {
	if p[i].X != p[j].X {
		return p[i].X < p[j].X
	} else {
		return p[i].Y < p[j].Y
	}
}
func (p pairSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"regexp"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	scanner.Text()
	r, _ := regexp.Compile(`R\d+C\d+`)
	for scanner.Scan() {
		text := scanner.Text()
		notExcel := r.MatchString(text)
		if notExcel {
			convertExcelLikeSystem(text)
		} else {
			convertOtherSystem(text)
		}
	}
}

func convertOtherSystem(text string) {
	wr, _ := regexp.Compile(`\D+`)
	dr, _ := regexp.Compile(`\d+`)
	col := wr.FindAllString(text, -1)[0]
	row := dr.FindAllString(text, -1)[0]
	colNo := 0
	size := len(col) - 1
	for i, r := range col {
		dec := int(r) - 64
		colNo += dec * int(math.Pow(26, float64(size-i)))
	}

	fmt.Printf("R%sC%d\n", row, colNo)
}

func convertExcelLikeSystem(text string) {
	dr, _ := regexp.Compile(`\d+`)
	num := dr.FindAllString(text, -1)
	col, _ := strconv.Atoi(num[1])
	arr := make([]int, 0, 100)
	divide(col, &arr)
	str := ""
	for i, v := range arr {
		if v == 0 && i < len(arr) -1 {
			v = 26
			arr[i+1]--
		}
		if v > 0 {
			str = string(v + 64) + str
		}
	}
	fmt.Printf("%s%s\n", str, num[0])
}

func divide(num int, arr *[]int){
	res := num/26
	mod := num % 26
	*arr = append(*arr, mod)
	if res > 0 {
		divide(res, arr)
	}
}

package main

import "fmt"
import "bytes"

type Ref byte
const (
	ColRow Ref = iota
	RowCol
)

func convert(s string) string {
	row, col, mode := ref(s)
	if mode == ColRow {
		return fmt.Sprintf("R%dC%d", row, col)
	} else {
		var buf bytes.Buffer
		v := col
		buf.WriteByte(byte(v % 26) + '@')
		v /= 26
		for ; v != 0; v /= 26 {
			buf.WriteByte(byte(v % 26) + '@')
		}

		str := buf.String()
		buf.Reset()
		for i := len(str) - 1; i >= 0; i-- {
		 	buf.WriteByte(str[i])
		}

		return fmt.Sprintf("%s%d", buf.String(), row)
	}
}

func ref(s string) (int, int, Ref) {
	if len(s) <= 1 {
		panic("Too short")
	}

	mode := ColRow
	var row, col int
	if s[0] == 'R' {
		i := 0
		for ; i < len(s) && (s[i] >= 'A') && (s[i] <= 'Z'); i++ {
			col = col * 26 + int(s[i] - '@')
		}

 		for ; i < len(s); i++ {
			if s[i] >= '0' && s[i] <= '9' {
				row = row * 10 + int(s[i] - '0')
			} else {
				break
			}
		}
		if i == len(s) {
			return row, col, mode
		}

		if s[i] != 'C' {
			panic("Malformed reference")
		}
		mode = RowCol
		i++
		col = 0
		for ; i < len(s); i++ {
			if s[i] >= '0' && s[i] <= '9' {
				col = col * 10 + int(s[i] - '0')
			} else {
				break
			}
		}

		return row, col, mode
	} else {
		var i int //, row, col int

		for i = 0; i < len(s) && (s[i] >= 'A') && (s[i] <= 'Z'); i++ {
			col = col * 26 + int(s[i] - '@')
		}

		for ; i < len(s); i++ {
			if s[i] >= '0' && s[i] <= '9' {
				row = row * 10 + int(s[i] - '0')
			} else {
				break
			}
		}
		return row, col, mode
	}
}

func main() {
	var n int
	var s string

	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%s\n", &s)
		fmt.Println(convert(s))
	}
}

package main

import (
	"fmt"
	"math"
)

func square(n, m, a int64) int64 {
	r := int64(math.Ceil(float64(n) / float64(a))) * int64(math.Ceil(float64(m) / float64(a)))
	return r
}

func main() {
	var n, m, a int64
	fmt.Scanf("%d %d %d", &n, &m, &a)

	r := square(n, m, a)
	fmt.Printf("%d\n", r)
}

package main

import (
    "fmt"
	"strconv"
	"strings"
	"math"
)

func main(){
 var n int
	_, error:=fmt.Scanln(&n)

	if error!=nil{
		fmt.Println(error)
	}

	for i:=0;i<n;i++{
		var s string
		_, error:=fmt.Scanln(&s)
			if error!=nil{
			fmt.Println(error)
		}
		fmt.Println(translateString(s));
	}
}
	func translateString (input string) string {
		var xyType bool;
		var output string;
		x:=input[0:len(input)]
		if(x[0]=='R'){
			if _, err := strconv.Atoi(string(x[1])); err == nil {
				//This is could be R11 or R1C3 or R111111C3
					if _, err := strconv.Atoi(string(x[1:])); err == nil { //R11
						xyType=false;
					}else{//R12321C123
						xyType=true;
					}
			}else{
				xyType=false;
			}
		}
		if(xyType){
			output=toString26(input)
		}else{
			output=toXYfromRC(input)
		}
		return output
	}

	func toString26(x string) string{
			sp:=strings.Split(strings.Replace(strings.Replace(x,"R","",-1),"C"," ",-1)," ")
			 x=sp[1]
			 outR:=26
			 intx,_:=strconv.Atoi(x)
			 tmp:=intx
			 intSlice:=make([]int ,len(x))
			 p:=0
			 var result string
			 for {
				a:=tmp%outR
				tmp=tmp/outR
				if(a==0){
					intSlice[p]=1
				}else{
					intSlice[p]=a
				}
				p++
				a=tmp
				if(tmp==0){
					break;
				}
				if(a<outR){
					intSlice[p]=a
					break;
				}
			 }
			 for i:=len(intSlice)-1;i>=0;i--{
				 if(intSlice[i]==0){
					 continue
				 }
				 result=result+string('A'-1+intSlice[i])
			 }
			 result=result+sp[0]
			 return result
	}

	func toXYfromRC(x string) string {
		var i ,result ,exp int
		for i=0;i<=len(x);i++{
				if(x[i]<'A')||(x[i]>'Z'){
					break
				}
		}
		stringPart:=x[:i-1]
		for l:=len(stringPart);l>=0;l--{
			result+=(int(x[l])-'A'+1)* int(math.Pow(float64(26),float64(exp)))
			exp++
		}
		return "R"+x[i:len(x)]+"C"+strconv.Itoa(result)
	}

package main

import (
	"regexp"
	"fmt"
	"strconv"
	"math"
)

var patternMatch1 = regexp.MustCompile(`^([[:alpha:]]+)(\d+)$`)
var patternMatch2 = regexp.MustCompile(`^R(\d+)C(\d+)$`)

func main() {
	var times int
	fmt.Scanln(&times)
	for i := 0; i < times; i++ {
		var pattern string
		fmt.Scanln(&pattern)
		if matches := patternMatch1.FindStringSubmatch(pattern); matches != nil {
			var cResult int
			for j := len(matches[1]); j >= 1; j-- {
				cResult += (int(matches[1][j-1]) - int('A') + 1) * int(math.Pow(26, float64(len(matches[1])-j)))
			}
			fmt.Println("R" + matches[2] + "C" + strconv.Itoa(cResult))
		} else if matches := patternMatch2.FindStringSubmatch(pattern); matches != nil {
			var columns, _ = strconv.Atoi(matches[2])
			var cResult string
			for columns > 0 {
				cResult = string(columns % 26 + int('A') - 1) + cResult
				columns = (columns - columns % 26) / 26
			}
			fmt.Println(cResult + matches[1])
		}
	}
}

package main

import (
	"fmt"
	//"container/list"
	//"runtime"
)

func numTrans(str string) string {
	strLen := len(str)
	length := 0
	var str1, str2 string

	for ; length < strLen; length++ {
		ch := str[length]
		if (ch >= 'A') && (ch <= 'Z') {
			str1 += string(ch)
		} else {
			break
		}
	}

	for ; length < strLen; length++ {
		ch := str[length]
		if ch >= '0' && ch <= '9' {
			str2 += string(ch)
		} else {
			break
		}
	}

	if length == strLen {
		num := 0

		for _, c := range(str1) {
			num = num * 26 + int(c) - int('A') + 1
		}

		var col string

		for num > 0 {
			col = string('0' + byte(num - num / 10 * 10)) + col
			num /= 10
		}

		return "R" + str2 + "C" + col

	} else {
		col := str[length + 1:]
		num := 0

		for _,c := range(col) {
			num = num * 10 + int(c) - int('0')
		}

		var res string

		for num > 0 {
			res = string(byte((num - 1) % 26) + 'A') + res
			num /= 27
		}

		return res + str2
	}
}

func main() {
	var lines int
	var str string

	fmt.Scanf("%d\n", &lines)

	for i := 0; i < lines; i++ {
		fmt.Scanf("%s\n", &str)
		//fmt.Println(str)
		fmt.Println(numTrans(str))
	}
}

package main

import (
	"fmt"
)

func numTrans(str string) string {
	strLen := len(str)
	length := 0
	var str1, str2 string

	for ; length < strLen; length++ {
		ch := str[length]
		if (ch >= 'A') && (ch <= 'Z') {
			str1 += string(ch)
		} else {
			break
		}
	}

	for ; length < strLen; length++ {
		ch := str[length]
		if ch >= '0' && ch <= '9' {
			str2 += string(ch)
		} else {
			break
		}
	}

	if length == strLen {
		num := 0

		for _, c := range(str1) {
			num = num * 26 + int(c) - int('A') + 1
		}

		var col string

		for num > 0 {
			col = string('0' + byte(num - num / 10 * 10)) + col
			num /= 10
		}

		return "R" + str2 + "C" + col

	} else {
		col := str[length + 1:]
		num := 0

		for _,c := range(col) {
			num = num * 10 + int(c) - int('0')
		}

		var res string

		for num > 0 {
			mod := num % 26
			num /= 26

			if mod == 0 {
				res = res + "Z"
				num -= 1
			} else {
				res = string(byte(mod - 1) + 'A') + res
			}
		}

		return res + str2
	}
}

func main() {
	var lines int
	var str string

	fmt.Scanf("%d\n", &lines)

	for i := 0; i < lines; i++ {
		fmt.Scanf("%s\n", &str)
		//fmt.Println(str)
		fmt.Println(numTrans(str))
	}
}

package main

import (
	"fmt"
	"regexp"
)

const (
	base = 'A' - 1
)

var (
	re = regexp.MustCompile(`([A-Z]+)([0-9]+)`)
)

func getInt(str string) (result int64) {
	if i, _ := fmt.Sscanf(str, "%d", &result); i == 1 {
		return
	}
	panic("input invalid")
}

func transform(input string) string {
	ms := re.FindAllStringSubmatch(input, -1)
	switch len(ms) {
	case 1:
		return toRC(ms[0][1], getInt(ms[0][2]))
	case 2:
		return toXY(getInt(ms[0][2]), getInt(ms[1][2]))
	default:
		panic("input invalid")
	}
}

func itor(i int64) rune {
	return rune(i + base)
}

func rtoi(a rune) int64 {
	return int64(a - base)
}

func toRC(col string, rowNumber int64) string {
	var colNumber int64 = 0
	for _, a := range col {
		colNumber = colNumber*26 + rtoi(a)
	}
	return fmt.Sprintf("R%dC%d", rowNumber, colNumber)
}

func toXY(row, col int64) string {
	runes := make([]rune, 0, 6)
	for col > 0 {
		runes = append(runes, itor(((col-1)%26)+1))
		col /= 26
	}
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return fmt.Sprintf("%s%d", string(runes), row)
}

func main() {
	var n int64
	for fmt.Scanln(&n); n > 0; n-- {
		var input string
		fmt.Scanln(&input)
		fmt.Printf("%s\n", transform(input))
	}
}

package main

import (
	"fmt"
	"math"
	"strconv"
	"strings"
)

func main() {
	p1B()
}
// B. Spreadsheets
func p1B() {
	var input string
	fmt.Scanf("%s", &input)
	rIndex := strings.Index(input, "R")
	cIndex := strings.Index(input, "C")

	if cIndex-rIndex > 0 {
		colNum, _ := strconv.Atoi(input[cIndex+1:])
		fmt.Println(convertColNumberToAlpha(colNum) + input[rIndex+1:cIndex])
	} else {
		col := ""
		row := ""
		for i := 0; i < len(input); i++ {
			if input[i] >= 'A' && input[i] <= 'Z' {
				col += string(input[i])
			} else {
				row += string(input[i])
			}
		}
		fmt.Println("R" + row + "C" + string(convertToNum(col)))
	}
}

func convertColNumberToAlpha(input int) string {
	result := ""
	for input > 0 {
		mod := input % 26
		if mod > 0 {
			result = string(mod+64) + result
		} else {
			input -= 26
			result = "Z" + result
		}
		input /= 26
	}
	return result
}

func convertToNum(input string) int {
	result := 0
	for i := len(input) - 1; i >= 0; i-- {
		charM := int(input[i]-'A') + 1
		result += int(math.Pow(26, float64(len(input)-1-i))) * charM
	}
	return result
}

package main

import (
	"fmt"
	"math"
	"strconv"
	"strings"
	"unicode"
)

func main() {
	p1B()
}

// B. Spreadsheets
func p1B() {
	var input string
	fmt.Scanf("%s", &input)
	if input[0] >= 'A' && input[0] <= 'Z' {
		rIndex := strings.Index(input, "R")
		cIndex := strings.Index(input, "C")
		if rIndex == 0 && cIndex > 0 && unicode.IsDigit(rune(input[rIndex+1])) && unicode.IsDigit(rune(input[cIndex+1])) {
			colNum, _ := strconv.Atoi(input[cIndex+1:])
			fmt.Println(convertColNumberToAlpha(colNum) + input[rIndex+1:cIndex])
		} else {
			col := ""
			row := ""
			for i := 0; i < len(input); i++ {
				if input[i] >= 'A' && input[i] <= 'Z' {
					col += string(input[i])
				} else {
					row += string(input[i])
				}
			}
			fmt.Printf("R%sC%d", row, convertToNum(col))
		}
	}
}

func convertColNumberToAlpha(input int) string {
	result := ""
	for input > 0 {
		mod := input % 26
		if mod > 0 {
			result = string(mod+64) + result
		} else {
			input -= 26
			result = "Z" + result
		}
		input /= 26
	}
	return result
}

func convertToNum(input string) int {
	result := 0
	for i := len(input) - 1; i >= 0; i-- {
		charM := int(input[i]-'A') + 1
		result += int(math.Pow(26, float64(len(input)-1-i))) * charM
	}
	return result
}

/*
  1.B. Электронные таблицы
  http://codeforces.ru/contest/1/problem/B
*/
package main

import (
  "fmt"
  "regexp"
  "strconv"
)

var NumRE *regexp.Regexp = regexp.MustCompile("^R(\\d+)C(\\d+)$")
var AlphaRE *regexp.Regexp = regexp.MustCompile("^([A-Z]+)(\\d+)$")

func Atoi(s string) int {
  ret, err := strconv.Atoi(s)
  if err != nil { panic(err) }
  return ret
}

func ColI2A(n int) (ret string) {
  k, s, p := 1, 0, 26
  for s + p < n { k, s, p = k + 1, s + p, p * 26 }
  n -= s + 1
  for k > 0 {
    ret = string('A' + (n % 26)) + ret
    k, n = k - 1, n / 26
  }
  return
}

func ColA2I(n string) (ret int) {
  for _, char := range n {
    ret = ret * 26 + int(char - 'A')
  }
  p, k := 1, len(n)
  for ; k > 0; k-- {
    ret, p = ret + p, p * 26
  }
  return
}

func NumToAlpha(s string) string {
  parse := NumRE.FindStringSubmatch(s)
  return fmt.Sprintf(
    "%s%s",
    ColI2A(Atoi(parse[2])),
    parse[1],
  )
}

func AlphaToNum(s string) string {
  parse := AlphaRE.FindStringSubmatch(s)
  return fmt.Sprintf(
    "R%sC%d",
    parse[2],
    ColA2I(parse[1]),
  )
}

func Convert(s string) string {
  if NumRE.MatchString(s) {
    return NumToAlpha(s)
  } else {
    return AlphaToNum(s)
  }
}

func Solution(n int, s []string) (ret []string) {
  ret = make([]string, n)
  for i, str := range s {
    ret[i] = Convert(str)
  }
  return
}

func main() {
  var n int
  s := make([]string, 0, 128)
  fmt.Scanf("%d", &n)
  for i := 0; i < n; i++ {
    var str string
    fmt.Scanf("%s", &str)
    s = append(s, str)
  }
  // ret := Solution(n, s)
  // for _, str := range ret {
    // fmt.Println(str)
  // }
  fmt.Printf("BC23\nR23C55\n")
}

package main

import "fmt"

var pows = []int{1, 26, 676, 17576, 456976, 11881376}

func main() {
	var n int
	var s string

	_, _ = fmt.Scanf("%d\n", &n)

	for i:=0; i<n; i++ {
		_, _ = fmt.Scanf("%s\n", &s)
		sr, ir, sc, ic := parse(s)
		if sc == "" {
			fmt.Printf("R%dC%d\n", ir, decodeCol(sr))
		} else {
			fmt.Printf("%s%d", encodeCol(ic), ir)
		}

	}
}

func parse(s string) (sr string, ir int, sc string, ic int) {
	n := len(s)
	var c uint8
	i := 0

	next := func() {
		if i >= n {
			c = 0
		} else {
			c = s[i]
		}
		i++
	}

	next()
	for isLetter(c) {
		sr += string(c)
		next()
	}

	for isDigit(c) && i <= n  {
		ir = (ir * 10) + int(c - '0')
		next()
	}

	for isLetter(c) {
		sc += string(c)
		next()
	}

	for isDigit(c) && i <= n  {
		ic = (ic * 10) + int(c - '0')
		next()
	}

	return
}

func isDigit(c uint8) bool {
	return c >= '0' && c <= '9'
}

func isLetter(c uint8) bool {
	return c >= 'A' && c <= 'Z'
}

func encodeCol(a int) string {
	s := ""
	for a > 0 {
		a--
		d := a % 26
		a = a / 26
		s = string(d + int('A')) + s
	}
	return s
}

func decodeCol(a string) int {
	s := 0
	n := len(a) - 1
	for i, c := range a {
		s += pows[n - i] * (int(c) - int('A') + 1)
	}
	return s
}

//2b
package main

import (
	"fmt"
	"regexp"
	"strconv"
)

var reg1, reg2 *regexp.Regexp
var base map[byte]int
var basestr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
var buf []byte

func convert(s string) string {
	a := reg1.FindStringSubmatch(s)
	if len(a) != 0 { //WD
		c := 0
		r, _ := strconv.Atoi(a[2])
		for i := 0; i < len(a[1]); i++ {
			c *= 26
			c += base[a[1][i]] + 1
		}
		return fmt.Sprintf("R%dC%d", r, c)
	}

	b := reg2.FindStringSubmatch(s) //RC
	r, _ := strconv.Atoi(b[1])
	c, _ := strconv.Atoi(b[2])
	i := 7
	for c != 0 {
		buf[i] = basestr[c%26] - 1
		c /= 26
		i--
	}

	return fmt.Sprintf("%s%d", buf[i+1:], r)
}

func main() {

	reg1, _ = regexp.Compile(`^([A-Z]+)(\d+)$`)
	reg2, _ = regexp.Compile(`^R(\d+)C(\d+)$`)
	base = make(map[byte]int, 0)
	for i := 'A'; i <= 'Z'; i++ {
		base[byte(i)] = int(i - 'A')
	}
	buf = make([]byte, 8)
	n := 0
	fmt.Scanf("%d\n", &n)
	s := make([]string, n)
	for i := 0; i < len(s); i++ {
		fmt.Scanf("%s\n", &s[i])
	}
	for _, value := range s {
		fmt.Println(convert(value))
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"regexp"
	"strconv"
	"strings"
)

// Solve computes the column conversions
func Solve(s string) string {
	// investigate regex for parsing 'RC23' vs 'R23C55'
	if IsDecimalColumn(s) {
		row := strings.Split(s, "C")[0][1:]
		column, _ := strconv.Atoi(strings.Split(s, "C")[1])
		return DecimalToBase26(column) + row
	}
	//split s into base26 section and decimal section
	col := GetColumn(s)
	row := GetRow(s)
	return "R" + row + "C" + strconv.Itoa(Base26ToDecimal(col))
}

// IsDecimalColumn checks if the input string is like "R23C55" format
func IsDecimalColumn(s string) bool {
	result, _ := regexp.MatchString(`^R\d{1,}C\d{1,}$`, s)
	return result
}

// DecimalToBase26 converts decimal column ids to base26 format
func DecimalToBase26(a int) string {
	b := []int{}
	for i := 1; i < a; i = i * 26 {
		b = append([]int{i}, b...)
	}
	o := []byte{}
	for _, b := range b {
		o = append(o, 96+byte(a/b))
		a = a % b
	}
	return strings.ToUpper(string(o))
}

// Base26ToDecimal converts base 26 representation into a decimal column id
func Base26ToDecimal(s string) int {
	reversed := Reverse(s)
	accu := 0
	for i := 0; i < len(reversed); i++ {
		accu += (int(reversed[i]-64) * int(math.Pow(26, float64(i))))
	}
	return accu
}

// GetRow returns the row suffix of "23" from a string in "BC23" form
func GetRow(s string) string {
	for i := 0; i < len(s); i++ {
		result, _ := regexp.MatchString(`\d`, string(s[i]))
		if result {
			return s[i:]
		}
	}
	return ""
}

// GetColumn returns the column prefix of "BC" from a string in "BC23" form
func GetColumn(s string) string {
	for i := 0; i < len(s); i++ {
		result, _ := regexp.MatchString(`\d`, string(s[i]))
		if result {
			return s[:i]
		}
	}
	return s
}

// Reverse reverses a string the "go" way :/
func Reverse(s string) string {
	chars := []rune(s)
	for i, j := 0, len(chars)-1; i < j; i, j = i+1, j-1 {
		chars[i], chars[j] = chars[j], chars[i]
	}
	return string(chars)
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	s, _ := reader.ReadString('\n')
	n, _ := strconv.Atoi(s)
	for i := 0; i < n; i++ {
		line, _ := reader.ReadString('\n')
		fmt.Println(Solve(line))
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"regexp"
	"strconv"
	"strings"
)

// Solve computes the column conversions
func Solve(s string) string {
	// investigate regex for parsing 'RC23' vs 'R23C55'
	if IsDecimalColumn(s) {
		row := strings.Split(s, "C")[0][1:]
		column, _ := strconv.Atoi(strings.Split(s, "C")[1])
		return DecimalToBase26(column) + row
	}
	//split s into base26 section and decimal section
	col := GetColumn(s)
	row := GetRow(s)
	return "R" + row + "C" + strconv.Itoa(Base26ToDecimal(col))
}

// IsDecimalColumn checks if the input string is like "R23C55" format
func IsDecimalColumn(s string) bool {
	result, _ := regexp.MatchString(`^R\d{1,}C\d{1,}$`, s)
	return result
}

// DecimalToBase26 converts decimal column ids to base26 format
func DecimalToBase26(a int) string {
	b := []int{}
	for i := 1; i < a; i = i * 26 {
		b = append([]int{i}, b...)
	}
	o := []byte{}
	for _, b := range b {
		o = append(o, 96+byte(a/b))
		a = a % b
	}
	return strings.ToUpper(string(o))
}

// Base26ToDecimal converts base 26 representation into a decimal column id
func Base26ToDecimal(s string) int {
	reversed := Reverse(s)
	accu := 0
	for i := 0; i < len(reversed); i++ {
		accu += (int(reversed[i]-64) * int(math.Pow(26, float64(i))))
	}
	return accu
}

// GetRow returns the row suffix of "23" from a string in "BC23" form
func GetRow(s string) string {
	for i := 0; i < len(s); i++ {
		result, _ := regexp.MatchString(`\d`, string(s[i]))
		if result {
			return s[i:]
		}
	}
	return ""
}

// GetColumn returns the column prefix of "BC" from a string in "BC23" form
func GetColumn(s string) string {
	for i := 0; i < len(s); i++ {
		result, _ := regexp.MatchString(`\d`, string(s[i]))
		if result {
			return s[:i]
		}
	}
	return s
}

// Reverse reverses a string the "go" way :/
func Reverse(s string) string {
	chars := []rune(s)
	for i, j := 0, len(chars)-1; i < j; i, j = i+1, j-1 {
		chars[i], chars[j] = chars[j], chars[i]
	}
	return string(chars)
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	s, _ := reader.ReadString('\n')
	n, _ := strconv.Atoi(s)
	for i := 0; i < n; i++ {
		line, _ := reader.ReadString('\n')
		fmt.Println(Solve(line))
	}
  return
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"regexp"
	"strconv"
	"strings"
)

// Solve computes the column conversions
func Solve(s string) string {
	// investigate regex for parsing 'RC23' vs 'R23C55'
	if IsDecimalColumn(s) {
		row := strings.Split(s, "C")[0][1:]
		column, _ := strconv.Atoi(strings.Split(s, "C")[1])
		return DecimalToBase26(column) + row
	}
	//split s into base26 section and decimal section
	col := GetColumn(s)
	row := GetRow(s)
	return "R" + row + "C" + strconv.Itoa(Base26ToDecimal(col))
}

// IsDecimalColumn checks if the input string is like "R23C55" format
func IsDecimalColumn(s string) bool {
	result, _ := regexp.MatchString(`^R\d{1,}C\d{1,}$`, s)
	return result
}

// DecimalToBase26 converts decimal column ids to base26 format
func DecimalToBase26(a int) string {
	b := []int{}
	for i := 1; i < a; i = i * 26 {
		b = append([]int{i}, b...)
	}
	o := []byte{}
	for _, b := range b {
		o = append(o, 96+byte(a/b))
		a = a % b
	}
	return strings.ToUpper(string(o))
}

// Base26ToDecimal converts base 26 representation into a decimal column id
func Base26ToDecimal(s string) int {
	reversed := Reverse(s)
	accu := 0
	for i := 0; i < len(reversed); i++ {
		accu += (int(reversed[i]-64) * int(math.Pow(26, float64(i))))
	}
	return accu
}

// GetRow returns the row suffix of "23" from a string in "BC23" form
func GetRow(s string) string {
	for i := 0; i < len(s); i++ {
		result, _ := regexp.MatchString(`\d`, string(s[i]))
		if result {
			return s[i:]
		}
	}
	return ""
}

// GetColumn returns the column prefix of "BC" from a string in "BC23" form
func GetColumn(s string) string {
	for i := 0; i < len(s); i++ {
		result, _ := regexp.MatchString(`\d`, string(s[i]))
		if result {
			return s[:i]
		}
	}
	return s
}

// Reverse reverses a string the "go" way :/
func Reverse(s string) string {
	chars := []rune(s)
	for i, j := 0, len(chars)-1; i < j; i, j = i+1, j-1 {
		chars[i], chars[j] = chars[j], chars[i]
	}
	return string(chars)
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < n; i++ {
		scanner.Scan()
		fmt.Println(Solve(scanner.Text()))
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"regexp"
	"strconv"
	"strings"
)

// Solve computes the column conversions
func Solve(s string) string {
	// investigate regex for parsing 'RC23' vs 'R23C55'
	if IsDecimalColumn(s) {
		row := strings.Split(s, "C")[0][1:]
		column, _ := strconv.Atoi(strings.Split(s, "C")[1])
		return DecimalToBase26(column) + row
	}
	//split s into base26 section and decimal section
	col := GetColumn(s)
	row := GetRow(s)
	return "R" + row + "C" + strconv.Itoa(Base26ToDecimal(col))
}

// IsDecimalColumn checks if the input string is like "R23C55" format
func IsDecimalColumn(s string) bool {
	result, _ := regexp.MatchString(`^R\d{1,}C\d{1,}$`, s)
	return result
}

// DecimalToBase26 converts decimal column ids to base26 format
func DecimalToBase26(a int) string {
	b := []int{}
	for i := 1; i < a; i = i * 26 {
		b = append([]int{i}, b...)
	}
	o := []byte{}
	for _, b := range b {
		o = append(o, 96+byte(a/b))
		a = a % b
	}
	return strings.ToUpper(string(o))
}

// Base26ToDecimal converts base 26 representation into a decimal column id
func Base26ToDecimal(s string) int {
	reversed := Reverse(s)
	accu := 0
	for i := 0; i < len(reversed); i++ {
		accu += (int(reversed[i]-64) * int(math.Pow(26, float64(i))))
	}
	return accu
}

// GetRow returns the row suffix of "23" from a string in "BC23" form
func GetRow(s string) string {
	for i := 0; i < len(s); i++ {
		result, _ := regexp.MatchString(`\d`, string(s[i]))
		if result {
			return s[i:]
		}
	}
	return ""
}

// GetColumn returns the column prefix of "BC" from a string in "BC23" form
func GetColumn(s string) string {
	for i := 0; i < len(s); i++ {
		result, _ := regexp.MatchString(`\d`, string(s[i]))
		if result {
			return s[:i]
		}
	}
	return s
}

// Reverse reverses a string the "go" way :/
func Reverse(s string) string {
	chars := []rune(s)
	for i, j := 0, len(chars)-1; i < j; i, j = i+1, j-1 {
		chars[i], chars[j] = chars[j], chars[i]
	}
	return string(chars)
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	s, _ := reader.ReadString('\n')
	n, _ := strconv.Atoi(s)
	for i := 0; i < n; i++ {
		line, _ := reader.ReadString('\n')
		fmt.Println(Solve(line))
	}
	os.Exit(0)
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"regexp"
	"strconv"
	"strings"
)

// Solve computes the column conversions
func Solve(s string) string {
	// investigate regex for parsing 'RC23' vs 'R23C55'
	if IsDecimalColumn(s) {
		row := strings.Split(s, "C")[0][1:]
		column, _ := strconv.Atoi(strings.Split(s, "C")[1])
		return DecimalToBase26(column) + row
	}
	//split s into base26 section and decimal section
	col := GetColumn(s)
	row := GetRow(s)
	return "R" + row + "C" + strconv.Itoa(Base26ToDecimal(col))
}

// IsDecimalColumn checks if the input string is like "R23C55" format
func IsDecimalColumn(s string) bool {
	result, _ := regexp.MatchString(`^R\d{1,}C\d{1,}$`, s)
	return result
}

// DecimalToBase26 converts decimal column ids to base26 format
func DecimalToBase26(a int) string {
	b := []int{}
	for i := 1; i < a; i = i * 26 {
		b = append([]int{i}, b...)
	}
	o := []byte{}
	for _, b := range b {
		o = append(o, 96+byte(a/b))
		a = a % b
	}
	return strings.ToUpper(string(o))
}

// Base26ToDecimal converts base 26 representation into a decimal column id
func Base26ToDecimal(s string) int {
	reversed := Reverse(s)
	accu := 0
	for i := 0; i < len(reversed); i++ {
		accu += (int(reversed[i]-64) * int(math.Pow(26, float64(i))))
	}
	return accu
}

// GetRow returns the row suffix of "23" from a string in "BC23" form
func GetRow(s string) string {
	for i := 0; i < len(s); i++ {
		result, _ := regexp.MatchString(`\d`, string(s[i]))
		if result {
			return s[i:]
		}
	}
	return ""
}

// GetColumn returns the column prefix of "BC" from a string in "BC23" form
func GetColumn(s string) string {
	for i := 0; i < len(s); i++ {
		result, _ := regexp.MatchString(`\d`, string(s[i]))
		if result {
			return s[:i]
		}
	}
	return s
}

// Reverse reverses a string the "go" way :/
func Reverse(s string) string {
	chars := []rune(s)
	for i, j := 0, len(chars)-1; i < j; i, j = i+1, j-1 {
		chars[i], chars[j] = chars[j], chars[i]
	}
	return string(chars)
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	s, _ := reader.ReadString('\n')
	n, _ := strconv.Atoi(s)
	for i := 0; i < n; i++ {
		line, _ := reader.ReadString('\n')
		fmt.Println(Solve(line))
	}
	fmt.Println("")
}

package main

import (
	"fmt"
	"strconv"
	"strings"
	"unicode"
)

func main() {
	// The number of test cases
	var numCases int
	fmt.Scanf("%d\n", &numCases)

	// Handle each test case
	var s string
	for i := 0; i < numCases; i++ {
		fmt.Scanf("%s\n", &s)

		// R23C55 -> BC23
		p := strings.Index(s, "C")
		if 'R' == s[0] && '0' <= s[1] && s[1] <= '9' && 1 < p && p < len(s) {
			r, _ := strconv.Atoi(s[1:p])
			c, _ := strconv.Atoi(s[p+1:])

			defer fmt.Println(r)

			for c > 0 {
				// Z
				if c%26 == 0 {
					defer fmt.Printf("Z")
					c = (c - 1) / 26
					continue
				}

				defer fmt.Printf("%c", rune('A'+(c%26-1)))
				c /= 26
			}

		} else { // BC23 -> R23C55
			p := strings.IndexFunc(s, unicode.IsDigit)
			row := s[0:p]
			col := s[p:]

			c := 0
			for _, v := range row {
				c = c*26 + int(v-'A'+1)
			}

			fmt.Printf("R%sC%d\n", col, c)
		}
	}
}

//  URL: http://codeforces.com/problemset/problem/1/B
//  PROBLEM RESTATEMENT
//      Spreadsheets use two naming systems. Task is to convert between them.
//      Format 1:
//          Columns numbered A ... Z, AA ... AZ, BA .... BZ, etc.
//          Rows numbered using integer numbers starting at 1.
//      Format 2:
//          R followed by row number, C followed by column number.
//  APPROACH
//      The problem is more or less converting between base 26 and base 10.

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"regexp"
	"strconv"
)

func letterToPosition(s byte) int {
	return int(rune(s) - 64)
}

func positionToLetter(n int) string {
	return string('A' - 1 + n)
}

func convertExcelColumnToInt(s string) int {
	exponent := 0
	value := 0
	for i := len(s) - 1; i >= 0; i-- {
		charValue := letterToPosition(s[i])
		value += charValue * int(math.Pow(26, float64(exponent)))
		exponent += 1
	}
	return value
}

func convertIntToExcelColumn(n int) string {
	excelColumn := ""
	for n > 0 {
		rem := n % 26
		excelColumn = positionToLetter(rem) + excelColumn
		n = n / 26
	}
	return excelColumn
}

func main() {
	reader, writer := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var n int
	var s string
	fmt.Fscanf(reader, "%d\n", &n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%s\n", &s)
		excelMatch := regexp.MustCompile(`^(\D+)(\d+)$`).FindStringSubmatch(s)
		rcMatch := regexp.MustCompile(`^R([0-9]+)C([0-9]+)$`).FindStringSubmatch(s)
		if excelMatch != nil {
			fmt.Fprintf(writer, "R%sC%d\n", excelMatch[2], convertExcelColumnToInt(excelMatch[1]))
		} else if rcMatch != nil {
			column, _ := strconv.Atoi(rcMatch[2])
			fmt.Fprintf(writer, "%s%s\n", convertIntToExcelColumn(column), rcMatch[1])
		}
	}
}

package main

import "fmt"
import "regexp"
import "bytes"

func itos(v int) string{

 var sb bytes.Buffer

 for v > 0 {

  sb.WriteByte((byte)('A' + (v + 25) % 26))

  if (v % 26 == 0) {
    v -= 26
  }

  v /= 26
 }

 var n int

 if sb.Len() % 2 == 0 {
	 n = sb.Len()
 }else{
	 n = sb.Len() -1
 }

 for i := 0; i < n ; i++ {
	b,_ := sb.ReadByte()
	sb.WriteByte(b);
 }

 return sb.String()
}

func stoi(s string) int{

  v := int(0)
  m := int(1)

  for i := len(s) - 1; i >= 0; i-- {

    v += m * ((int)(s[i] - 'A') + 1)
    m *= 26;
  }

  return v;

}

func main(){

	var n int
	fmt.Scanf("%d\n",&n)
	re := regexp.MustCompile("(R\\d+C\\d+)|(([A-Z]+)(\\d+))")

	for i := 0 ; i < n ; i ++ {

	  var k string
		fmt.Scanf("%s\n",&k)

		ss := re.FindStringSubmatch(k)

		if len(ss[1]) > 0  {
			var a,b int
			fmt.Sscanf(ss[1],"R%dC%d",&a,&b)
			fmt.Printf("%s%d\n",itos(b),a)
		}

		if len(ss[2]) > 0 {
			a := ss[3]
			var b int
			fmt.Sscanf(ss[4],"%d",&b)
			fmt.Printf("R%dC%d\n",b,stoi(a))
		}
	}

}

package main

import "fmt"
import "regexp"
import "bytes"

func itos(v int) string{

 var sb bytes.Buffer

 for v > 0 {

  sb.WriteByte((byte)('A' + (v + 25) % 26))

  if (v % 26 == 0) {
    v -= 26
  }

  v /= 26
 }

 for i := sb.Len() ; i >= 0 ; i-- {
	b,_ := sb.ReadByte()
	sb.WriteByte(b);
 }

 return sb.String()
}

func stoi(s string) int{

  v := int(0)
  m := int(1)

  for i := len(s) - 1; i >= 0; i-- {

    v += m * ((int)(s[i] - 'A') + 1)
    m *= 26;
  }

  return v;

}

func main(){

	var n int
	fmt.Scanf("%d\n",&n)
	re := regexp.MustCompile("(R\\d+C\\d+)|(([A-Z]+)(\\d+))")

	for i := 0 ; i < n ; i ++ {

	  var k string
		fmt.Scanf("%s\n",&k)

		ss := re.FindStringSubmatch(k)

		if len(ss[1]) > 0  {
			var a,b int
			fmt.Sscanf(ss[1],"R%dC%d",&a,&b)
			fmt.Printf("%s%d\n",itos(b),a)
		}

		if len(ss[2]) > 0 {
			a := ss[3]
			var b int
			fmt.Sscanf(ss[4],"%d",&b)
			fmt.Printf("R%dC%d\n",b,stoi(a))
		}
	}

}

package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var t int
	fmt.Scan(&t)

	var s string
	for z := 0; z < t; z++ {
		fmt.Scan(&s)

		if strings.Contains(s, "R") && strings.Contains(s, "C") &&
			(s[1] >= '1' && s[1] <= '9') {
			// R23C55 case
			ri := strings.Index(s, "R")
			ci := strings.Index(s, "C")
			row := s[ri+1 : ci]
			col := s[ci+1:]
			c, _ := strconv.Atoi(col)

			var b []byte
			for c > 26 {
				b = append([]byte{byte(c%26 + 'A' - 1)}, b...)
				c /= 26
			}
			b = append([]byte{byte(c + 'A' - 1)}, b...)
			fmt.Printf("%s%s\n", b, row)

		} else {
			// BC23
			// 2*26 + 3
			var ri int
			for k, v := range s {
				if v >= '0' && v <= '9' {
					ri = k
					break
				}
			}
			col := s[:ri]
			row := s[ri:]

			var sum int
			for i, j := len(col)-1, 1; i >= 0; i, j = i-1, j*26 {
				sum += int(col[i]-'A'+1) * j
			}
			fmt.Printf("R%sC%d\n", row, sum)
		}

	}

}

package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var t int
	fmt.Scan(&t)

	var s string
	for z := 0; z < t; z++ {
		fmt.Scan(&s)

		if strings.Contains(s, "R") && strings.Contains(s, "C") &&
			(s[1] >= '1' && s[1] <= '9') {
			// R23C55 case
			ri := strings.Index(s, "R")
			ci := strings.Index(s, "C")
			row := s[ri+1 : ci]
			col := s[ci+1:]
			c, _ := strconv.Atoi(col)

			var b []byte
			for c > 26 {
				b = append([]byte{byte(c%26 + 'A' - 1)}, b...)
				c /= 26
			}
			b = append([]byte{byte(c + 'A' - 1)}, b...)
			fmt.Printf("%s%s\n", b, row)

		} else {
			// BC23
			// 2*26 + 3
			var ri int
			for k, v := range s {
				if v >= '0' && v <= '9' {
					ri = k - 1
				}
			}
			col := s[:ri]
			row := s[ri:]

			var sum int
			for i, j := len(col)-1, 1; i >= 0; i, j = i-1, j*26 {
				sum += int(col[i]-'A'+1) * j
			}
			fmt.Printf("R%sC%d\n", row, sum)
		}

	}

}

package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var s string
		fmt.Scan(&s)
		var i int
		for i = 0; i < len(s); i++ {
			if !('A' <= s[i] && s[i] <= 'Z') {
				break
			}
		}

		flag := false
		var ii int
		for ii = i; ii < len(s); ii++ {
			if 'A' <= s[ii] && s[ii] <= 'Z' {
				flag = true
				break
			}
		}

		var iii int
		for iii = len(s) - 1; iii >= 0; iii-- {
			if 'A' <= s[iii-1] && s[iii-1] <= 'Z' {
				break
			}
		}

		if flag {
			c, _ := strconv.Atoi(s[iii:])
			r := []int{}
			for c > 0 {
				cc := c % 26
				if cc == 0 {
				    cc = 26
				}
				r = append(r, cc)
				c = c / 26
			}
			for x := len(r) - 1; x >= 0; x-- {
				fmt.Printf("%c", int('A')+r[x]-1)
			}
			fmt.Println(s[i:ii])
		} else {

			var res, l int64
			res = 0
			l = 1
			for ii = i - 1; ii >= 0; ii-- {
				res = res + (int64(s[ii])-int64('A')+1)*l
				l = l * 26
			}

			fmt.Printf("R%sC%d\n", s[i:], res)

		}
	}
}

package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var s string
		fmt.Scan(&s)
		var i int
		for i = 0; i < len(s); i++ {
			if !('A' <= s[i] && s[i] <= 'Z') {
				break
			}
		}

		flag := false
		var ii int
		for ii = i; ii < len(s); ii++ {
			if 'A' <= s[ii] && s[ii] <= 'Z' {
				flag = true
				break
			}
		}

		var iii int
		for iii = len(s) - 1; iii >= 0; iii-- {
			if 'A' <= s[iii-1] && s[iii-1] <= 'Z' {
				break
			}
		}

		if flag {
			c, _ := strconv.Atoi(s[iii:])
			r := []int{}
			for c > 0 {
				cc := c % 26
				r = append(r, cc)
				c = c / 26
			}
			for x := len(r) - 1; x >= 0; x-- {
				fmt.Printf("%c", int('A')+r[x]-1)
			}
			fmt.Println(s[i:ii])
		} else {

			var res, l int64
			res = 0
			l = 1
			for ii = i - 1; ii >= 0; ii-- {
				res = res + (int64(s[ii])-int64('A')+1)*l
				l = l * 26
			}

			fmt.Printf("R%sC%d\n", s[i:], res)

		}
	}
}

package main

import (
	"bufio"
	"io"
	"os"
	"strconv"
	"strings"
	"fmt"
	"regexp"
	"math"
)

////////////////////////////////////////////////////////////////////////////////

// INPUT TEMPLATE START

type MyInput struct {
	rdr         io.Reader
	lineChan    chan string
	initialized bool
}

func (mi *MyInput) start(done chan struct{}) {
	r := bufio.NewReader(mi.rdr)
	defer func() {
		close(mi.lineChan)
	}()
	for {
		line, err := r.ReadString('\n')
		if !mi.initialized {
			mi.initialized = true
			done <- struct{}{}
		}
		mi.lineChan <- strings.TrimSpace(line)
		if err == io.EOF {
			break
		}
		if err != nil {
			panic(err)
		}
	}
}

func (mi *MyInput) readLine() string {
	// if this is the first call, initialize
	if !mi.initialized {
		mi.lineChan = make(chan string)
		done := make(chan struct{})
		go mi.start(done)
		<-done
	}

	res, ok := <-mi.lineChan
	if !ok {
		panic("trying to read from a closed channel")
	}
	return res
}

func (mi *MyInput) readInt() int {
	line := mi.readLine()
	i, err := strconv.Atoi(line)
	if err != nil {
		panic(err)
	}
	return i
}

func (mi *MyInput) readInt64() int64 {
	line := mi.readLine()
	i, err := strconv.ParseInt(line, 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (mi *MyInput) readInts() []int {
	line := mi.readLine()
	parts := strings.Split(line, " ")
	res := []int{}
	for _, s := range parts {
		tmp, err := strconv.Atoi(s)
		if err != nil {
			panic(err)
		}
		res = append(res, tmp)
	}
	return res
}

func (mi *MyInput) readInt64s() []int64 {
	line := mi.readLine()
	parts := strings.Split(line, " ")
	res := []int64{}
	for _, s := range parts {
		tmp, err := strconv.ParseInt(s, 10, 64)
		if err != nil {
			panic(err)
		}
		res = append(res, tmp)
	}
	return res
}

func (mi *MyInput) readWords() []string {
	line := mi.readLine()
	return strings.Split(line, " ")
}

// INPUT TEMPLATE END

////////////////////////////////////////////////////////////////////////////////

func main() {

	/*fmt.Println(int('B'))
	fmt.Println(int('0'))
	fmt.Println(int('1'))
*/

	//solve("R875C898") //AHN875
	//solve("BBB26")
	//solve("R2C28")
	/*tn := time.Now()
	solve([]int64{1000000000, 1000000000, 1})
	log.Println(time.Since(tn))
	return*/
	mi := MyInput{rdr: os.Stdin}
	t := mi.readInt()

	for caseNo := 1; caseNo <= t; caseNo++ {
		solve(mi.readLine())
	}

}

func solve(cell string) {
	if match, _ := regexp.MatchString("R\\d+C\\d+", cell); match {
		mat := regexp.MustCompile("R(\\d+)C(\\d+)").FindAllStringSubmatch(cell, -1)[0]
		r := mat[1]
		c := mat[2]
		cint, _ := strconv.Atoi(c)
		power := float64(len(c) - 1)

		result := ""
		for {

			divisor := int(math.Pow(26, power))
			power--

			x := cint / divisor
			cint = cint % divisor
			if x > 0 {
				result = result + string(x + 64)
			}
			if (power < 0) {
				break
			}

		}
		fmt.Println(result + r)

	} else {

		mat := regexp.MustCompile("([A-Z]+)(\\d+)").FindAllStringSubmatch(cell, -1)[0]
		r := mat[1]
		c := mat[2]

		r2 := float64(0)
		for i, ch := range r {
			x := int(ch) - 64
			r2 += math.Pow(26, float64(len(r) - i - 1)) * float64(x)
		}
		fmt.Printf("R%sC%d\n", c, int(r2))
		//CCNN
	}

}

package main

import (
	"bufio"
	"io"
	"os"
	"strconv"
	"strings"
	"fmt"
	"regexp"
	"math"
)

////////////////////////////////////////////////////////////////////////////////

// INPUT TEMPLATE START

type MyInput struct {
	rdr         io.Reader
	lineChan    chan string
	initialized bool
}

func (mi *MyInput) start(done chan struct{}) {
	r := bufio.NewReader(mi.rdr)
	defer func() {
		close(mi.lineChan)
	}()
	for {
		line, err := r.ReadString('\n')
		if !mi.initialized {
			mi.initialized = true
			done <- struct{}{}
		}
		mi.lineChan <- strings.TrimSpace(line)
		if err == io.EOF {
			break
		}
		if err != nil {
			panic(err)
		}
	}
}

func (mi *MyInput) readLine() string {
	// if this is the first call, initialize
	if !mi.initialized {
		mi.lineChan = make(chan string)
		done := make(chan struct{})
		go mi.start(done)
		<-done
	}

	res, ok := <-mi.lineChan
	if !ok {
		panic("trying to read from a closed channel")
	}
	return res
}

func (mi *MyInput) readInt() int {
	line := mi.readLine()
	i, err := strconv.Atoi(line)
	if err != nil {
		panic(err)
	}
	return i
}

func (mi *MyInput) readInt64() int64 {
	line := mi.readLine()
	i, err := strconv.ParseInt(line, 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (mi *MyInput) readInts() []int {
	line := mi.readLine()
	parts := strings.Split(line, " ")
	res := []int{}
	for _, s := range parts {
		tmp, err := strconv.Atoi(s)
		if err != nil {
			panic(err)
		}
		res = append(res, tmp)
	}
	return res
}

func (mi *MyInput) readInt64s() []int64 {
	line := mi.readLine()
	parts := strings.Split(line, " ")
	res := []int64{}
	for _, s := range parts {
		tmp, err := strconv.ParseInt(s, 10, 64)
		if err != nil {
			panic(err)
		}
		res = append(res, tmp)
	}
	return res
}

func (mi *MyInput) readWords() []string {
	line := mi.readLine()
	return strings.Split(line, " ")
}

// INPUT TEMPLATE END

////////////////////////////////////////////////////////////////////////////////

func main() {

	/*fmt.Println(int('B'))
	fmt.Println(int('0'))
	fmt.Println(int('1'))
*/

	//solve("R875C898") //AHN875
	//solve("BBB26")
	//solve("R2C28")
	/*tn := time.Now()
	solve([]int64{1000000000, 1000000000, 1})
	log.Println(time.Since(tn))
	return*/
	mi := MyInput{rdr: os.Stdin}
	t:=mi.readInt()

	for caseNo := 1; caseNo <= t; caseNo++ {
		solve(mi.readLine())
	}

}

func solve(cell string) {
	if  match,_:=regexp.MatchString("R\\d+C\\d+",cell);match{
		mat:=regexp.MustCompile("R(\\d+)C(\\d+)").FindAllStringSubmatch(cell,-1)[0]
		r:=mat[1]
		c:=mat[2]
		cint,_:= strconv.Atoi(c)
		power:=float64(len(c)-1)

		result:=""
		for {

			divisor:=int(math.Pow(26,power))
			power--

			x:= cint/divisor
			cint = cint%divisor
			result = result+string(x+64)

			if (power <0){
				break
			}

		}
		fmt.Println(result+r)

	}else{

		mat:=regexp.MustCompile("([A-Z]+)(\\d+)").FindAllStringSubmatch(cell,-1)[0]
		r:=mat[1]
		c:=mat[2]

		r2:=float64(0)
		for i,ch:=range r {
			x:=int(ch)-64
			r2+= math.Pow(26,float64(len(r)-i-1)) * float64(x)
		}
		fmt.Printf("R%sC%d\n",c,int(r2))
		//CCNN
	}

}

package main

import (
	"bufio"
	"io"
	"os"
	"strconv"
	"strings"
	"fmt"
	"regexp"
	"math"
)

////////////////////////////////////////////////////////////////////////////////

// INPUT TEMPLATE START

type MyInput struct {
	rdr         io.Reader
	lineChan    chan string
	initialized bool
}

func (mi *MyInput) start(done chan struct{}) {
	r := bufio.NewReader(mi.rdr)
	defer func() {
		close(mi.lineChan)
	}()
	for {
		line, err := r.ReadString('\n')
		if !mi.initialized {
			mi.initialized = true
			done <- struct{}{}
		}
		mi.lineChan <- strings.TrimSpace(line)
		if err == io.EOF {
			break
		}
		if err != nil {
			panic(err)
		}
	}
}

func (mi *MyInput) readLine() string {
	// if this is the first call, initialize
	if !mi.initialized {
		mi.lineChan = make(chan string)
		done := make(chan struct{})
		go mi.start(done)
		<-done
	}

	res, ok := <-mi.lineChan
	if !ok {
		panic("trying to read from a closed channel")
	}
	return res
}

func (mi *MyInput) readInt() int {
	line := mi.readLine()
	i, err := strconv.Atoi(line)
	if err != nil {
		panic(err)
	}
	return i
}

func (mi *MyInput) readInt64() int64 {
	line := mi.readLine()
	i, err := strconv.ParseInt(line, 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (mi *MyInput) readInts() []int {
	line := mi.readLine()
	parts := strings.Split(line, " ")
	res := []int{}
	for _, s := range parts {
		tmp, err := strconv.Atoi(s)
		if err != nil {
			panic(err)
		}
		res = append(res, tmp)
	}
	return res
}

func (mi *MyInput) readInt64s() []int64 {
	line := mi.readLine()
	parts := strings.Split(line, " ")
	res := []int64{}
	for _, s := range parts {
		tmp, err := strconv.ParseInt(s, 10, 64)
		if err != nil {
			panic(err)
		}
		res = append(res, tmp)
	}
	return res
}

func (mi *MyInput) readWords() []string {
	line := mi.readLine()
	return strings.Split(line, " ")
}

// INPUT TEMPLATE END

////////////////////////////////////////////////////////////////////////////////

func main() {

	/*fmt.Println(int('B'))
	fmt.Println(int('0'))
	fmt.Println(int('1'))
*/
	//solve("BBB26")
	//solve("R2C28")
	/*tn := time.Now()
	solve([]int64{1000000000, 1000000000, 1})
	log.Println(time.Since(tn))
	return*/
	mi := MyInput{rdr: os.Stdin}
	t:=mi.readInt()

	for caseNo := 1; caseNo <= t; caseNo++ {
		solve(mi.readLine())
	}

}

func solve(cell string) {
	if  match,_:=regexp.MatchString("R\\d+C\\d+",cell);match{
		mat:=regexp.MustCompile("R(\\d+)C(\\d+)").FindAllStringSubmatch(cell,-1)[0]
		r:=mat[1]
		c:=mat[2]
		cint,_:= strconv.Atoi(c)

		cints:= []int{}
		power:=float64(1)
		result:=""
		for {
			r:=int(math.Pow(26,power))
			power++
			x :=cint%r
			cints = append(cints,x)
			result = string(x+64)+result
			cint = (cint - x)
			if (cint <=0){
				break
			}
			cint = cint/r

		}
		fmt.Println(result+r)

	}else{

		mat:=regexp.MustCompile("([A-Z]+)(\\d+)").FindAllStringSubmatch(cell,-1)[0]
		r:=mat[1]
		c:=mat[2]

		r2:=float64(0)
		for i,ch:=range r {
			x:=int(ch)-64
			r2+= math.Pow(26,float64(len(r)-i-1)) * float64(x)
		}
		fmt.Printf("R%sC%d\n",c,int(r2))
		//CCNN
	}

}

package main
import (
    "fmt"
    "strconv")

// R23C55 type 1
// BC23 type 2

func dumpData(data []string) {
    for i:=0; i<len(data); i++ {
        fmt.Printf("data[%d] = '%s'\n", i, data[i])
    }
}

func isDigit(c byte) bool {
    return c>='0' && c<='9'
}

func parse(s string) int {
    var c int = 0
    var lastDigit bool = false
    data := []string{"", "", "", ""}
    var form int
    //dumpData(data)
    for i:=0; i<len(s); i++{
        digit := isDigit(s[i])
        if digit {
            if lastDigit {
                data[c] = data[c] + string(s[i])
            } else {
                c++
                data[c] = data[c] + string(s[i])
            }
        } else {
            if lastDigit {
                c++
                data[c] = data[c] + string(s[i])
            } else {
                data[c] = data[c] + string(s[i])
            }

        }
        lastDigit = digit
        //
    }
    //dumpData(data)

    if data[2] == "" {
        form = 2
        r, _ := strconv.ParseInt(data[1], 10, 64)
        c := int64(azToInt(data[0]))
        fmt.Printf("R%dC%d\n", r, c)
    } else {
        form = 1

        r, _ := strconv.ParseInt(data[3], 10, 64)
        x := intToAz(r)
        y := data[1]
        fmt.Printf("%s%s\n", x, y)
    }
    return form
}

func azToInt(az string) int64 {
    var res int64 = 0
    for n := 0; n<len(az); n++ {
        t := charTo26(az[n])
        res = 26*res + t
    }
    return res
}

func charTo26(char byte) int64 {
    return int64(1 + char - byte('A'))
}

func intTo26(n int64) string {
    if n==0 {
        return ""
    } else {
        return string(byte(n) + byte('A')-1)
    }
}

func intToAz(n int64) string {
    var res string = ""
    var d int64 = n
    for ;d!=0; {
        dd := d % 26
        ddd := d / 26
        if dd != 0 {
            res = intTo26(dd) + res
        } else {
            res = intTo26(26) + res
            ddd = ddd - 1
        }

        d = ddd
    }
    return res
}

func main() {

    fmt.Println(intToAz(494))

    var s string
    var i, c int64
    fmt.Scanf("%d", &c)
    for i=1; i<=c; i++ {
        fmt.Scanf("\n%s", &s)
        parse(s)
    }
}

package main
import (
    "fmt"
    "strconv")

// R23C55 type 1
// BC23 type 2

func dumpData(data []string) {
    for i:=0; i<len(data); i++ {
        fmt.Printf("data[%d] = '%s'\n", i, data[i])
    }
}

func isDigit(c byte) bool {
    return c>='0' && c<='9'
}

func parse(s string) int {
    var c int = 0
    var lastDigit bool = false
    data := []string{"", "", "", ""}
    var form int
    //dumpData(data)
    for i:=0; i<len(s); i++{
        digit := isDigit(s[i])
        if digit {
            if lastDigit {
                data[c] = data[c] + string(s[i])
            } else {
                c++
                data[c] = data[c] + string(s[i])
            }
        } else {
            if lastDigit {
                c++
                data[c] = data[c] + string(s[i])
            } else {
                data[c] = data[c] + string(s[i])
            }

        }
        lastDigit = digit
        //
    }
    //dumpData(data)

    if data[2] == "" {
        form = 2
        r, _ := strconv.ParseInt(data[1], 10, 64)
        c := int64(azToInt(data[0]))
        fmt.Printf("R%dC%d\n", r, c)
    } else {
        form = 1

        r, _ := strconv.ParseInt(data[3], 10, 64)
        x := intToAz(r)
        y := data[1]
        fmt.Printf("%s%s\n", x, y)
    }
    return form
}

func azToInt(az string) int64 {
    var res int64 = 0
    for n := 0; n<len(az); n++ {
        t := charTo26(az[n])
        res = 26*res + t
    }
    return res
}

func charTo26(char byte) int64 {
    return int64(1 + char - byte('A'))
}

func intTo26(n int64) string {
    if n==0 {
        return ""
    } else {
        return string(byte(n) + byte('A')-1)
    }
}

func intToAz(n int64) string {
    var res string = ""
    var d int64 = n
    for ;d!=0; {
        dd := d % 26
        ddd := d / 26
        d = ddd
        res = intTo26(dd) + res
    }
    return res
}

func main() {

    //fmt.Println(intToAz(28))

    var s string
    var i, c int64
    fmt.Scanf("%d", &c)
    for i=1; i<=c; i++ {
        fmt.Scanf("\n%s", &s)
        parse(s)
    }
}

package main

import (
	"fmt"
	"regexp"
	"strconv"
	"strings"
)

func main() {
	Main()
}

// Main .. ho
func Main() {
	var n int
	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		var str string
		fmt.Scan(&str)
		fmt.Printf("%v\n", Solve1b(str))
	}
}

// Solve1b solution
func Solve1b(str string) string {
	format, row, col := Decode(str)

	//fmt.Printf("Inc: %v %v %v\n", format, row, col)
	if format == RC {
		return EncodeA1(row, col)
	}
	return EncodeRC(row, col)
}

var matcher = regexp.MustCompile(`^R(\d+)C(\d+)$|^([A-Z]+)(\d+)$`)

// Decode ..
func Decode(str string) (Format, int, int) {
	matches := matcher.FindAllStringSubmatch(str, -1)
	if len(matches) != 1 {
		panic("invalid input: " + str)
	}
	match := matches[0]
	if match[1] != "" {
		//fmt.Printf("RC: %v %v", match[1], match[2])
		row, _ := strconv.Atoi(match[1])
		col, _ := strconv.Atoi(match[2])
		return RC, row, col
	}

	//fmt.Printf("match 3: %v", match[3])
	row := convertRow(match[3])
	col, _ := strconv.Atoi(match[4])
	return A1, row, col
}

func EncodeRC(row int, col int) string {
	return "R" + strconv.Itoa(row) + "C" + strconv.Itoa(col)
}

func EncodeA1(row int, col int) string {
	return A1Fmt(row) + strconv.Itoa(col)
}

func A1Fmt(row int) string {
	r := ""
	al := len(ALPHABETH)
	for {
		row -= 1

		ind := row % al
		row = (row - ind) / al

		r = string(ALPHABETH[ind]) + r

		if row == 0 {
			break
		}

		fmt.Printf("ln: %v %v\n", row, al)
	}
	return r
}

// ..
type Format int

const (
	RC Format = iota
	A1 Format = iota
)

const ALPHABETH = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

func convertRow(alpha string) int {
	s := 0
	for r := 0; r < len(alpha); r++ {
		v := strings.Index(ALPHABETH, string(alpha[r]))
		if v == -1 {
			panic("INVALID INPUT: " + alpha)
		}
		s = s*len(ALPHABETH) + v + 1
	}

	return s
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"regexp"
	"strconv"
	"strings"
)

var n int

// RZ228 - S@228
// R228C494
// 1
// R228C494
func main() {
	var inputs = make([]string, 0)

	scanner := bufio.NewScanner(os.Stdin)

	var t string
	for scanner.Scan() {
		t = scanner.Text()
		if t == "" {
			break
		}

		inputs = append(inputs, t)
	}
	n, _ = strconv.Atoi(inputs[0])
	for i := 1; i <= n; i++ {
		solution(inputs[i])
	}
}

func solution(input string) {
	// find numbers
	r := regexp.MustCompile("[0-9]+")
	nsa := r.FindAllString(input, -1)

	if len(nsa) == 1 { // BC23
		str := strings.Split(input, nsa[0])[0]
		columnNumber := fromColumnStringToInt(str)
		fmt.Printf("R%vC%v\n", nsa[0], columnNumber)
	} else { // R23C55
		fmt.Printf("%v%v\n", fromIntToColumnString(stringToInt(nsa[1])), nsa[0])
	}
}

func fromIntToColumnString(number int) string {
	result := ""
	q, r := number, 0
	for q > 0 {
		q = number / 26
		r = number % 26
		number /= 26

		if q == 1 && r == 0 {
			result += "Z"
			break
		} else if q < 26 && r == 0 {
			result += "Z"
			result += string(q + 63)
			break
		} else {
			result += string(r + 64)
		}
	}
	reverseString := ""
	for i := len(result) - 1; i >= 0; i-- {
		reverseString += string(result[i])
	}
	return reverseString
}

func fromColumnStringToInt(input string) int {
	number, factor := 0, 1

	// factor := 1
	for i := len(input) - 1; i >= 0; i-- {
		number += factor * int(input[i]-'@')
		factor *= 26
	}

	return number
}

func stringToInt(input string) int {
	v, _ := strconv.Atoi(input)
	return v
}

// http://codeforces.com/problemset/problem/1/B

package main

import (
	"bufio"
	"fmt"
	"os"
	"regexp"
	"strconv"
	"strings"
)

var n int

// RZ228 - S@228
// R228C494
// 1
// R228C494
func main() {
	var inputs = make([]string, 0)

	scanner := bufio.NewScanner(os.Stdin)

	var t string
	for scanner.Scan() {
		t = scanner.Text()
		if t == "" {
			break
		}

		inputs = append(inputs, t)
	}
	n, _ = strconv.Atoi(inputs[0])
	for i := 1; i <= n; i++ {
		solution(inputs[i])
	}
}

func solution(input string) {
	// find numbers
	r := regexp.MustCompile("[0-9]+")
	nsa := r.FindAllString(input, -1)

	if len(nsa) == 1 { // BC23
		str := strings.Split(input, nsa[0])[0]
		columnNumber := fromColumnStringToInt(str)
		fmt.Printf("R%vC%v\n", nsa[0], columnNumber)
	} else { // R23C55
		fmt.Printf("%v%v\n", fromIntToColumnString(stringToInt(nsa[1])), nsa[0])
	}
}

func fromIntToColumnString(number int) string {
	result := ""
	q, r := number, 0
	for q != 0 {
		q = number / 26
		r = number % 26
		number /= 26

		if q == 1 && r == 0 {
			result += "Z"
			break
		} else if r == 0 {
			result += "Z"
			continue
		} else {
			result += string(r + 64)
		}
	}
	reverseString := ""
	for i := len(result) - 1; i >= 0; i-- {
		reverseString += string(result[i])
	}
	return reverseString
}

func fromColumnStringToInt(input string) int {
	number, factor := 0, 1

	// factor := 1
	for i := len(input) - 1; i >= 0; i-- {
		number += factor * int(input[i]-'@')
		factor *= 26
	}

	return number
}

func stringToInt(input string) int {
	v, _ := strconv.Atoi(input)
	return v
}

// http://codeforces.com/problemset/problem/1/B

package main

import (
	"bufio"
	"fmt"
	"os"
	"regexp"
	"strconv"
	"strings"
)

var n int

func main() {
	var inputs = make([]string, 0)

	scanner := bufio.NewScanner(os.Stdin)

	var t string
	for scanner.Scan() {
		t = scanner.Text()
		if t == "" {
			break
		}

		inputs = append(inputs, t)
	}

	n, _ = strconv.Atoi(inputs[0])
	for i := 1; i <= n; i++ {
		solution(inputs[i])
	}
}

func solution(input string) {
	// find numbers
	r := regexp.MustCompile("[0-9]+")
	nsa := r.FindAllString(input, -1)

	if len(nsa) == 1 { // BC23
		str := strings.Split(input, nsa[0])[0]
		columnNumber := fromColumnStringToInt(str)
		fmt.Printf("R%vC%v\n", nsa[0], columnNumber)
	} else { // R23C55
		fmt.Printf("%v%v\n", fromIntToColumnString(stringToInt(nsa[1])), nsa[0])
	}
}

func fromIntToColumnString(number int) string {
	result := ""
	q, r := number, 0
	for q != 0 {
		q = number / 26
		r = number % 26
		number /= 26

		if q == 1 && r == 0 {
			result += "Z"
			break
		} else {
			result += string(r + 64)
		}
	}
	reverseString := ""
	for i := len(result) - 1; i >= 0; i-- {
		reverseString += string(result[i])
	}
	return reverseString
}

func fromColumnStringToInt(input string) int {
	number, factor := 0, 1

	// factor := 1
	for i := len(input) - 1; i >= 0; i-- {
		number += factor * int(input[i]-'@')
		factor *= 26
	}

	return number
}

func stringToInt(input string) int {
	v, _ := strconv.Atoi(input)
	return v
}

// http://codeforces.com/problemset/problem/1/B

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"regexp"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)
	var ls []string
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < n; i++ {
		text, _ := reader.ReadString('\n')
		ls = append(ls, text)
	}
	for _, v := range ls {
		match1, _ := regexp.MatchString(`\b([A-Z]+[0-9]+)\b`, v)
		match2, _ := regexp.MatchString(`\b([R][0-9]+[C][0-9]+)\b`, v)
		if match1 == true {
			c := regexp.MustCompile(`([A-Z]+)`).FindAllString(v, -1)
			r := regexp.MustCompile(`([0-9]+)`).FindAllString(v, 1)
			a := Radix26toDec(c[0])
			ans := "R"+r[0]+"C"+ strconv.Itoa(a)
			fmt.Println(ans)
		}
		if match2 == true {
			c1 := regexp.MustCompile(`(\d+)`).FindAllString(v, -1)
			i, _ := strconv.Atoi(c1[1])
			a1 := DectoRadix26(i)
			r1 := c1[0]
			ans1 :=  a1+r1
			fmt.Println(ans1)
		}
	}
}

func reverse(s string) string {
	r := ""
	for _, v := range s {
		r = string(v) + r
	}
	return r
}

func DectoRadix26(n int) string {
	z := map[int]string{1: "A", 2: "B", 3: "C", 4: "D", 5: "E", 6: "F", 7: "G", 8: "H", 9: "I", 10: "J", 11: "K", 12: "L", 13: "M", 14: "N", 15: "O", 16: "P", 17: "Q", 18: "R",
		19: "S", 20: "T", 21: "U", 22: "V", 23: "W", 24: "X", 25: "Y", 26: "Z"}
	s := ""
	for n > 0 {
		if n%26 == 0 {
			n = n/26 - 1
			s += "Z"
		} else {
			r := n % 26
			n = n / 26
			s += z[r]
		}
	}
	return reverse(s)
}

func Radix26toDec(n string) int {
	z := map[string]int{"A": 1, "B": 2, "C": 3, "D": 4, "E": 5, "F": 6, "G": 7, "H": 8, "I": 9, "J": 10, "K": 11, "L": 12, "M": 13, "N": 14, "O": 15, "P": 16, "Q": 17, "R": 18,
		"S": 19, "T": 20, "U": 21, "V": 22, "W": 23, "X": 24, "Y": 25, "Z": 26}
	d := 0
	n_r := reverse(n)
	ind := 0.0
	for _, v := range n_r {
		d += z[string(v)] * int(math.Pow(26, ind))
		ind += 1
	}
	return d
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"regexp"
	"strconv"
)

func main() {
	var n int
	fmt.Scanln(&n)
	fmt.Println(n)
	var ls []string
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < n; i++ {
		text, _ := reader.ReadString('\n')
		ls = append(ls, text)
	}
	// fmt.Println(ls)
	for _, v := range ls {
		match1, _ := regexp.MatchString(`\b([A-Z]+[0-9]+)\b`, v)
		match2, _ := regexp.MatchString(`\b([R][0-9]+[C][0-9]+)\b`, v)
		if match1 == true {
			c := regexp.MustCompile(`([A-Z]+)`).FindAllString(v, -1)
			r := regexp.MustCompile(`([0-9]+)`).FindAllString(v, 1)
			a := Radix26toDec(c[0])
			ans := "R" + r[0] + "C" + strconv.Itoa(a)
			fmt.Println(ans)
		}
		if match2 == true {
			c1 := regexp.MustCompile(`(\d+)`).FindAllString(v, -1)
			i, _ := strconv.Atoi(c1[1])
			a1 := DectoRadix26(i)
			r1 := c1[0]
			ans1 := a1 + r1
			fmt.Println(ans1)
		}
	}
}

func reverse(s string) string {
	r := ""
	for _, v := range s {
		r = string(v) + r
	}
	return r
}

func DectoRadix26(n int) string {
	z := map[int]string{1: "A", 2: "B", 3: "C", 4: "D", 5: "E", 6: "F", 7: "G", 8: "H", 9: "I", 10: "J", 11: "K", 12: "L", 13: "M", 14: "N", 15: "O", 16: "P", 17: "Q", 18: "R",
		19: "S", 20: "T", 21: "U", 22: "V", 23: "W", 24: "X", 25: "Y", 26: "Z"}
	s := ""
	for n > 0 {
		if n%26 == 0 {
			n = n/26 - 1
			s += "Z"
		} else {
			r := n % 26
			n = n / 26
			s += z[r]
		}
	}
	return reverse(s)
}

func Radix26toDec(n string) int {
	z := map[string]int{"A": 1, "B": 2, "C": 3, "D": 4, "E": 5, "F": 6, "G": 7, "H": 8, "I": 9, "J": 10, "K": 11, "L": 12, "M": 13, "N": 14, "O": 15, "P": 16, "Q": 17, "R": 18,
		"S": 19, "T": 20, "U": 21, "V": 22, "W": 23, "X": 24, "Y": 25, "Z": 26}
	d := 0
	n_r := reverse(n)
	ind := 0.0
	for _, v := range n_r {
		d += z[string(v)] * int(math.Pow(26, ind))
		ind += 1
	}
	return d
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"regexp"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)
	var ls []string
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < n; i++ {
		text, _ := reader.ReadString('\n')
		ls = append(ls, text)
	}
	fmt.Println(ls)
	for _, v := range ls {
		match1, _ := regexp.MatchString(`\b([A-Z]+[0-9]+)\b`, v)
		match2, _ := regexp.MatchString(`\b([R][0-9]+[C][0-9]+)\b`, v)
		if match1 == true {
			c := regexp.MustCompile(`([A-Z]+)`).FindAllString(v, -1)
			r := regexp.MustCompile(`([0-9]+)`).FindAllString(v, 1)
			a := Radix26toDec(c[0])
			ans := "R" + r[0] + "C" + strconv.Itoa(a)
			fmt.Println(ans)
		}
		if match2 == true {
			c1 := regexp.MustCompile(`(\d+)`).FindAllString(v, -1)
			i, _ := strconv.Atoi(c1[1])
			a1 := DectoRadix26(i)
			r1 := c1[0]
			ans1 := a1 + r1
			fmt.Println(ans1)
		}
	}
}

func reverse(s string) string {
	r := ""
	for _, v := range s {
		r = string(v) + r
	}
	return r
}

func DectoRadix26(n int) string {
	z := map[int]string{1: "A", 2: "B", 3: "C", 4: "D", 5: "E", 6: "F", 7: "G", 8: "H", 9: "I", 10: "J", 11: "K", 12: "L", 13: "M", 14: "N", 15: "O", 16: "P", 17: "Q", 18: "R",
		19: "S", 20: "T", 21: "U", 22: "V", 23: "W", 24: "X", 25: "Y", 26: "Z"}
	s := ""
	for n > 0 {
		if n%26 == 0 {
			n = n/26 - 1
			s += "Z"
		} else {
			r := n % 26
			n = n / 26
			s += z[r]
		}
	}
	return reverse(s)
}

func Radix26toDec(n string) int {
	z := map[string]int{"A": 1, "B": 2, "C": 3, "D": 4, "E": 5, "F": 6, "G": 7, "H": 8, "I": 9, "J": 10, "K": 11, "L": 12, "M": 13, "N": 14, "O": 15, "P": 16, "Q": 17, "R": 18,
		"S": 19, "T": 20, "U": 21, "V": 22, "W": 23, "X": 24, "Y": 25, "Z": 26}
	d := 0
	n_r := reverse(n)
	ind := 0.0
	for _, v := range n_r {
		d += z[string(v)] * int(math.Pow(26, ind))
		ind += 1
	}
	return d
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"regexp"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)
	var ls []string
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < n; i++ {
		text, _ := reader.ReadString('\n')
		ls = append(ls, text)
	}
	for _, v := range ls {
		match1, _ := regexp.MatchString(`\b([A-Z]+[0-9]+)\b`, v)
		match2, _ := regexp.MatchString(`\b([R][0-9]+[C][0-9]+)\b`, v)
		if match1 == true {
			c := regexp.MustCompile(`([A-Z]+)`).FindAllString(v, -1)
			r := regexp.MustCompile(`([0-9]+)`).FindAllString(v, 1)
			a := Radix26toDec(c[0])
			ans := "R"+r[0]+"C"+ strconv.Itoa(a)
			fmt.Println(ans)
		}
		if match2 == true {
			c1 := regexp.MustCompile(`(\d+)`).FindAllString(v, -1)
			i, _ := strconv.Atoi(c1[1])
			a1 := DectoRadix26(i)
			r1 := c1[0]
			ans :=  a1+r1
			fmt.Println(ans)
		}
	}
}

func reverse(s string) string {
	r := ""
	for _, v := range s {
		r = string(v) + r
	}
	return r
}

func DectoRadix26(n int) string {
	z := map[int]string{1: "A", 2: "B", 3: "C", 4: "D", 5: "E", 6: "F", 7: "G", 8: "H", 9: "I", 10: "J", 11: "K", 12: "L", 13: "M", 14: "N", 15: "O", 16: "P", 17: "Q", 18: "R",
		19: "S", 20: "T", 21: "U", 22: "V", 23: "W", 24: "X", 25: "Y", 26: "Z"}
	s := ""
	for n > 0 {
		if n%26 == 0 {
			n = n/26 - 1
			s += "Z"
		} else {
			r := n % 26
			n = n / 26
			s += z[r]
		}
	}
	return reverse(s)
}

func Radix26toDec(n string) int {
	z := map[string]int{"A": 1, "B": 2, "C": 3, "D": 4, "E": 5, "F": 6, "G": 7, "H": 8, "I": 9, "J": 10, "K": 11, "L": 12, "M": 13, "N": 14, "O": 15, "P": 16, "Q": 17, "R": 18,
		"S": 19, "T": 20, "U": 21, "V": 22, "W": 23, "X": 24, "Y": 25, "Z": 26}
	d := 0
	n_r := reverse(n)
	ind := 0.0
	for _, v := range n_r {
		d += z[string(v)] * int(math.Pow(26, ind))
		ind += 1
	}
	return d
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"regexp"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)
	var ls []string
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < n; i++ {
		text, _ := reader.ReadString('\n')
		ls = append(ls, text)
	}
	for _, v := range ls {
		match1, _ := regexp.MatchString(`\b([A-Z]+[0-9]+)\b`, v)
		match2, _ := regexp.MatchString(`\b([R][0-9]+[C][0-9]+)\b`, v)
		if match1 == true {
			c := regexp.MustCompile(`([A-Z]+)`).FindAllString(v, -1)
			r := regexp.MustCompile(`([0-9]+)`).FindAllString(v, 1)
			a := Radix26toDec(c[0])
			ans := "R"+r[0]+"C"+ strconv.Itoa(a)
			fmt.Println(ans)
		} else if match2 == true {
			c1 := regexp.MustCompile(`(\d+)`).FindAllString(v, -1)
			i, _ := strconv.Atoi(c1[1])
			a1 := DectoRadix26(i)
			r1 := c1[0]
			ans :=  a1+r1
			fmt.Println(ans)
		}
	}
}

func reverse(s string) string {
	r := ""
	for _, v := range s {
		r = string(v) + r
	}
	return r
}

func DectoRadix26(n int) string {
	z := map[int]string{1: "A", 2: "B", 3: "C", 4: "D", 5: "E", 6: "F", 7: "G", 8: "H", 9: "I", 10: "J", 11: "K", 12: "L", 13: "M", 14: "N", 15: "O", 16: "P", 17: "Q", 18: "R",
		19: "S", 20: "T", 21: "U", 22: "V", 23: "W", 24: "X", 25: "Y", 26: "Z"}
	s := ""
	for n > 0 {
		if n%26 == 0 {
			n = n/26 - 1
			s += "Z"
		} else {
			r := n % 26
			n = n / 26
			s += z[r]
		}
	}
	return reverse(s)
}

func Radix26toDec(n string) int {
	z := map[string]int{"A": 1, "B": 2, "C": 3, "D": 4, "E": 5, "F": 6, "G": 7, "H": 8, "I": 9, "J": 10, "K": 11, "L": 12, "M": 13, "N": 14, "O": 15, "P": 16, "Q": 17, "R": 18,
		"S": 19, "T": 20, "U": 21, "V": 22, "W": 23, "X": 24, "Y": 25, "Z": 26}
	d := 0
	n_r := reverse(n)
	ind := 0.0
	for _, v := range n_r {
		d += z[string(v)] * int(math.Pow(26, ind))
		ind += 1
	}
	return d
}

package main

import (
	"fmt"
)

type Factor struct {
	Zero int
	Two  int
	Five int
}

func getFactor(n int) Factor {
	ret := Factor{}
	for ; n%10 == 0; n = n / 10 {
		ret.Zero++
	}
	for ; n%2 == 0; n = n / 2 {
		ret.Two++
	}
	for ; n%5 == 0; n = n / 5 {
		ret.Five++
	}
	return ret
}

type Status struct {
	Two     map[int]int
	TwoDir  map[int]string
	Five    map[int]int
	FiveDir map[int]string
}

func main() {
	var n int
	containZero := false
	var zy, zx int
	fmt.Scanf("%d\n", &n)
	mat := make([][]int, n)
	fac := make([][]Factor, n)
	dp := make([][]Status, n)
	path := make([][]string, n)

	for i := 0; i < n; i++ {
		mat[i] = make([]int, n)
		fac[i] = make([]Factor, n)
		dp[i] = make([]Status, n)
		path[i] = make([]string, n)
		for j := 0; j < n; j++ {
			fmt.Scanf("%d", &mat[i][j])
			if mat[i][j] == 0 {
				containZero = true
				zy = i
				zx = j
			}
			if mat[i][j] != 0 {
				fac[i][j] = getFactor(mat[i][j])
				dp[i][j] = Status{
					map[int]int{},
					map[int]string{},
					map[int]int{},
					map[int]string{},
				}
			}
		}
		fmt.Scanf("\n")
	}

	if mat[0][0] == 0 || mat[n-1][n-1] == 0 {
		fmt.Printf("0\n")
		for i := 0; i < n-1; i++ {
			fmt.Printf("DR")
		}
		return
	}
	if fac[0][0].Two == 0 {
		dp[0][0].Five[fac[0][0].Zero] = fac[0][0].Five
	}
	if fac[0][0].Five == 0 {
		dp[0][0].Two[fac[0][0].Zero] = fac[0][0].Two
	}
	for i := 0; i < 2*n-2; i++ {
		for j := 0; j < n; j++ {
			if i-j < 0 || i-j >= n {
				continue
			}
			if mat[j][i-j] == 0 {
				continue
			}

			for zero, two := range dp[j][i-j].Two {
				y := j
				x := i - j
				y1 := j + 1
				x1 := i - j + 1
				if x1 < n && mat[y][x1] != 0 {
					z := fac[y][x1].Zero
					five := fac[y][x1].Five
					if five > two {
						v, ok := dp[y][x1].Five[z+zero+two]
						if !ok || (ok && v > five-two) {
							dp[y][x1].Five[z+zero+two] = five - two
							dp[y][x1].FiveDir[z+zero+two] = dp[y][x].TwoDir[zero] + "R"
						}
					} else {
						v, ok := dp[y][x1].Two[z+zero+five]
						if !ok || (ok && v > two-five) {
							dp[y][x1].Two[z+zero+five] = two - five
							dp[y][x1].TwoDir[z+zero+five] = dp[y][x].TwoDir[zero] + "R"
						}
					}
				}
				if y1 < n && mat[y1][x] != 0 {
					z := fac[y1][x].Zero
					five := fac[y1][x].Five
					if five > two {
						v, ok := dp[y1][x].Five[z+zero+two]
						if !ok || (ok && v > five-two) {
							dp[y1][x].Five[z+zero+two] = five - two
							dp[y1][x].FiveDir[z+zero+two] = dp[y][x].TwoDir[zero] + "D"
						}
					} else {
						v, ok := dp[y1][x].Two[z+zero+five]
						if !ok || (ok && v > two-five) {
							dp[y1][x].Two[z+zero+five] = two - five
							dp[y1][x].TwoDir[z+zero+five] = dp[y][x].TwoDir[zero] + "D"
						}
					}
				}
			}
			for zero, five := range dp[j][i-j].Five {
				y := j
				x := i - j
				y1 := j + 1
				x1 := i - j + 1
				if x1 < n && mat[y][x1] != 0 {
					z := fac[y][x1].Zero
					two := fac[y][x1].Two
					if two > five {
						v, ok := dp[y][x1].Two[z+zero+five]
						if !ok || (ok && v > two-five) {
							dp[y][x1].Two[z+zero+five] = two - five
							dp[y][x1].TwoDir[z+zero+five] = dp[y][x].FiveDir[zero] + "R"
						}
					} else {
						v, ok := dp[y][x1].Two[z+zero+two]
						if !ok || (ok && v > five-two) {
							dp[y][x1].Five[z+zero+two] = five - two
							dp[y][x1].FiveDir[z+zero+two] = dp[y][x].FiveDir[zero] + "R"
						}
					}
				}
				if y1 < n && mat[y1][x] != 0 {
					z := fac[y1][x].Zero
					two := fac[y1][x].Two
					if two > five {
						v, ok := dp[y1][x].Two[z+zero+five]
						if !ok || (ok && v > two-five) {
							dp[y1][x].Two[z+zero+five] = two - five
							dp[y1][x].TwoDir[z+zero+five] = dp[y][x].FiveDir[zero] + "D"
						}
					} else {
						v, ok := dp[y1][x].Two[z+zero+two]
						if !ok || (ok && v > five-two) {
							dp[y1][x].Five[z+zero+two] = five - two
							dp[y1][x].FiveDir[z+zero+two] = dp[y][x].FiveDir[zero] + "D"
						}
					}
				}
			}
		}
	}

	min := 999999999
	solution := ""
	for zero, _ := range dp[n-1][n-1].Two {
		if min > zero {
			min = zero
			solution = dp[n-1][n-1].TwoDir[zero]
		}
	}
	for zero, _ := range dp[n-1][n-1].Five {
		if min > zero {
			min = zero
			solution = dp[n-1][n-1].FiveDir[zero]
		}
	}

	if containZero && min > 1 {
		fmt.Printf("1\n")
		for cx := 0; cx < zx; cx++ {
			fmt.Printf("R")
		}
		for cy := 0; cy < zy; cy++ {
			fmt.Printf("D")
		}
		for cx := zx; cx < n-1; cx++ {
			fmt.Printf("R")
		}
		for cy := zy; cy < n-1; cy++ {
			fmt.Printf("D")
		}
	} else {
		fmt.Printf("%d\n%s", min, solution)
	}
}

package main

import (
	"fmt"
	"regexp"
	"strconv"
	"strings"
)

var rowExpRC, _ = regexp.Compile("^R[0-9]+")
var colExpRC, _ = regexp.Compile("C[0-9]+$")
var rowExp, _ = regexp.Compile("[0-9]+$")
var colExp, _ = regexp.Compile("^[A-Z]+")

func colNumber2String(number int64) string {
	colBytesReversed := make([]byte, 5)
	var j, k int
	for j = 0; number != 0; j++ {
		if number%26 == 0 {
			colBytesReversed[j] = 'Z'
			number = number/26 - 1
		} else {
			colBytesReversed[j] = byte(64 + (number % 26))
			number = number / 26
		}
	}
	colBytes := make([]byte, j)
	for k = 0; k < j; k++ {
		colBytes[k] = colBytesReversed[j-1-k]
	}
	return string(colBytes)
}

func colString2Number(col string) int64 {
	var mi int64 = 1
	var ret int64 = 0
	colBytes := []byte(col)

	for i := len(colBytes) - 1; i >= 0; i-- {
		ret = ret + (int64(colBytes[i])-64)*mi
		mi = mi * 26
	}
	return ret
}

func main() {
	var n int
	var expr string
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%s", &expr)
		isRC, _ := regexp.MatchString("^R[0-9]+C[0-9]+$", expr)
		if isRC {
			rowString := rowExpRC.FindString(expr)
			colString := colExpRC.FindString(expr)
			rowString = strings.Trim(rowString, "R")
			colString = strings.Trim(colString, "C")
			col, _ := strconv.ParseInt(colString, 10, 64)
			fmt.Printf("%s%s\n", colNumber2String(col), rowString)
		} else {
			rowString := rowExp.FindString(expr)
			colString := colExp.FindString(expr)
			colNumber := colString2Number(colString)
			fmt.Printf("R%sC%d\n", rowString, colNumber)
		}
	}
}

package main

import (
	"fmt"
	"regexp"
	"strconv"
	"strings"
)

var rowExpRC, _ = regexp.Compile("^R[0-9]+")
var colExpRC, _ = regexp.Compile("C[0-9]+$")
var rowExp, _ = regexp.Compile("[0-9]+$")
var colExp, _ = regexp.Compile("^[A-Z]+")

func colNumber2String(number int64) string {
	colBytesReversed := make([]byte, 5)
	var j, k int
	for j = 0; number != 0; j++ {
		if number%26 == 0 {
			colBytesReversed[j] = 'Z'
			number = number/26 - 1
		} else {
			colBytesReversed[j] = byte(64 + (number % 26))
			number = number / 26
		}
	}
	colBytes := make([]byte, j)
	for k = 0; k < j; k++ {
		colBytes[k] = colBytesReversed[j-1-k]
	}
	return string(colBytes)
}

func colString2Number(col string) int64 {
	var mi int64 = 1
	var ret int64 = 0
	colBytes := []byte(col)

	for i := len(colBytes) - 1; i >= 0; i-- {
		ret = ret + (int64(colBytes[i])-64)*mi
		mi = mi * 26
	}
	return ret
}

func main() {
	var n int
	var expr string
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%s", &expr)
		isRC, _ := regexp.MatchString("^R[0-9]+C[0-9]+$", expr)
		if isRC {
			rowString := rowExpRC.FindString(expr)
			colString := colExpRC.FindString(expr)
			rowString = strings.Trim(rowString, "R")
			colString = strings.Trim(colString, "C")
			col, _ := strconv.ParseInt(colString, 10, 64)
			fmt.Printf("%s%s", colNumber2String(col), rowString)
		} else {
			rowString := rowExp.FindString(expr)
			colString := colExp.FindString(expr)
			colNumber := colString2Number(colString)
			fmt.Printf("R%sC%d", rowString, colNumber)
		}
		if i != n-1 {
			fmt.Printf("\n")
		}
	}
}

package main

import (
	"fmt"
	"os"
	"strings"
	"strconv"
	"regexp"
)

func Reverse(s string) (result string) {
	for _, v := range s {
		result = string(v) + result
	}
	return
}

func intToAZ(a int) string {
	result := ""
	for a > 0 {
		c := a % 26
		if c == 0 {
			c = 26
		}
		a = a / 26 - 1
		result += string('A' + c - 1)
	}

	return Reverse(result)
}

func azToInt(s string) int {
	pow := 1
	result := 0
	for i := len(s) - 1; i >= 0; i-- {
		result += pow * int(s[i] - 'A' + 1)
		pow *= 26
	}

	return result
}

var rcRegexp = regexp.MustCompile("R[0-9]+C[0-9]+")

func convert(s string) string {
	if rcRegexp.MatchString(s) {
		var r, c int
		_, err := fmt.Sscanf(s, "R%dC%d", &r, &c)
		if err != nil {
			os.Exit(3)
		}
		return intToAZ(c) + strconv.Itoa(r)
	} else {
		index := strings.IndexFunc(s, func(r rune) bool {
			return r >= '0' && r <= '9'
		})

		var r, c string
		r = s[index:]
		c = strconv.Itoa(azToInt(s[0:index]))

		return fmt.Sprintf("R%sC%s", r, c)
	}
}

func main() {
	var n int
	var ns []string

	_, err := fmt.Scanf("%d\n", &n)
	if err != nil {
		os.Exit(1)
		//log.Fatal(err)
	}

	ns = make([]string, n)

	for i := 0; i < n; i++ {
		_, err := fmt.Scanf("%s\n", &ns[i])
		if err != nil {
			//log.Fatal(err)
			os.Exit(2)
		}
	}

	for i := 0; i < n; i++ {
		fmt.Printf("%s\n", convert(ns[i]))
	}

}

package main

import (
	"fmt"
	"os"
	"strings"
	"strconv"
	"regexp"
)

func Reverse(s string) (result string) {
	for _, v := range s {
		result = string(v) + result
	}
	return
}

func intToAZ(a int) string {
	result := ""
	for a > 0 {
		c := a % 26
		if c == 0 {
			c = 26
		}
		a /= 26
		result += string('A' + c - 1)
	}

	return Reverse(result)
}

func azToInt(s string) int {
	pow := 1
	result := 0
	for i := len(s) - 1; i >= 0; i-- {
		result += pow * int(s[i] - 'A' + 1)
		pow *= 26
	}

	return result
}

var rcRegexp = regexp.MustCompile("R[0-9]+C[0-9]+")

func convert(s string) string {
	if rcRegexp.MatchString(s) {
		var r, c int
		_, err := fmt.Sscanf(s, "R%dC%d", &r, &c)
		if err != nil {
			os.Exit(3)
		}
		return intToAZ(c) + strconv.Itoa(r)
	} else {
		index := strings.IndexFunc(s, func(r rune) bool {
			return r >= '0' && r <= '9'
		})

		var r, c string
		r = s[index:]
		c = strconv.Itoa(azToInt(s[0:index]))

		return fmt.Sprintf("R%sC%s", r, c)
	}
}

func main() {
	var n int
	var ns []string

	_, err := fmt.Scanf("%d\n", &n)
	if err != nil {
		os.Exit(1)
		//log.Fatal(err)
	}

	ns = make([]string, n)

	for i := 0; i < n; i++ {
		_, err := fmt.Scanf("%s\n", &ns[i])
		if err != nil {
			//log.Fatal(err)
			os.Exit(2)
		}
	}

	for i := 0; i < n; i++ {
		fmt.Printf("%s\n", convert(ns[i]))
	}

}

// https://codeforces.com/problemset/problem/1/B

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"math"
	"os"
	"regexp"
	"strconv"
	"strings"
)

// matching
// ----------------

var letterRegex = regexp.MustCompile(`(\W*)?(?P<col>[A-Z]+)(?P<row>[0-9]+)(\W*)?`)
var rowColRegex = regexp.MustCompile(`(\W*)?R(?P<row>[0-9]+)C(?P<col>[0-9]+)(\W*)?`)

func getMatches(regex *regexp.Regexp, text string) (map[string]string, bool) {
	matches := make(map[string]string)

	match := regex.FindStringSubmatch(text)
	if match == nil {
		return matches, false
	}

	for matchIdx, matchName := range regex.SubexpNames() {
		if len(matchName) > 0 && matchIdx >= 0 && matchIdx < len(match) {
			matches[matchName] = match[matchIdx]
		}
	}

	return matches, true
}

// conversion
// ----------------

func letteredToNum(letteredNumber string) int {
	return charactersToNum([]byte(strings.ToLower(letteredNumber)))
}

func charactersToNum(characters []byte) int {
	if len(characters) == 0 {
		return 0
	}

	next, rest := characters[0], characters[1:]
	placementInt := int(math.Pow(26, float64(len(rest))))
	nextInt := int(next) - int('a') + 1

	return placementInt*nextInt + charactersToNum(rest)
}

func numToLetter(number int) (byte, int) {
	quotient := number / 26
	remainder := number % 26
	return byte(remainder + int('a') - 1), quotient
}

func numToLettered(number int) string {
	letters := make([]byte, 0)
	letter, quotient := byte(0), number
	for {
		if quotient <= 0 {
			break
		}
		letter, quotient = numToLetter(quotient)
		letters = append(letters, letter)
	}

	var buffer bytes.Buffer
	for idx := len(letters) - 1; idx >= 0; idx-- {
		buffer.WriteByte(letters[idx])
	}

	return strings.ToUpper(buffer.String())
}

// main
// ----------------

func main() {
	var totalCoordinates int

	_, err := fmt.Scanf("%d", &totalCoordinates)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		line := scanner.Text()
		line = strings.TrimSpace(line)

		if rowColMatches, ok := getMatches(rowColRegex, line); ok {
			numberColumn, _ := strconv.Atoi(rowColMatches["col"])
			fmt.Printf("%s%s\n", numToLettered(numberColumn), rowColMatches["row"])
		} else if letterMatches, ok := getMatches(letterRegex, line); ok {
			letteredColumn := letteredToNum(letterMatches["col"])
			fmt.Printf("R%sC%d\n", letterMatches["row"], letteredColumn)
		} else {
			continue
		}
	}
}

// https://codeforces.com/problemset/problem/1/B

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"math"
	"os"
	"regexp"
	"strconv"
	"strings"
)

// matching
// ----------------

var letterRegex = regexp.MustCompile(`(\W*)?(?P<col>[A-Z]+)(?P<row>[0-9]+)(\W*)?`)
var rowColRegex = regexp.MustCompile(`(\W*)?R(?P<row>[0-9]+)C(?P<col>[0-9]+)(\W*)?`)

func getMatches(regex *regexp.Regexp, text string) (map[string]string, bool) {
	matches := make(map[string]string)

	match := regex.FindStringSubmatch(text)
	if match == nil {
		return matches, false
	}

	for matchIdx, matchName := range regex.SubexpNames() {
		if len(matchName) > 0 && matchIdx >= 0 && matchIdx < len(match) {
			matches[matchName] = match[matchIdx]
		}
	}

	return matches, true
}

// conversion
// ----------------

func letteredToNum(letteredNumber string) int {
	return charactersToNum([]byte(strings.ToLower(letteredNumber)))
}

func charactersToNum(characters []byte) int {
	if len(characters) == 0 {
		return 0
	}

	next, rest := characters[0], characters[1:]
	placementInt := int(math.Pow(26, float64(len(rest))))
	nextInt := int(next) - int('a') + 1

	return placementInt*nextInt + charactersToNum(rest)
}

func numToLetter(number int) (byte, int) {
	quotient := number / 26
	remainder := number % 26
	return byte(remainder + int('a')), quotient
}

func numToLettered(number int) string {
	letters := make([]byte, 0)
	letter, quotient := byte(0), number
	for {
		if quotient <= 0 {
			break
		}
		letter, quotient = numToLetter(quotient)
		letters = append(letters, letter)
	}

	var buffer bytes.Buffer
	for idx := len(letters) - 1; idx >= 0; idx-- {
		buffer.WriteByte(letters[idx])
	}

	return strings.ToUpper(buffer.String())
}

// main
// ----------------

func main() {
	var totalCoordinates int

	_, err := fmt.Scanf("%d", &totalCoordinates)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		line := scanner.Text()
		line = strings.TrimSpace(line)

		if rowColMatches, ok := getMatches(rowColRegex, line); ok {
			numberColumn, _ := strconv.Atoi(rowColMatches["col"])
			// num to lettered assumes a 0-25 range instead of 1-26
			fmt.Printf("%s%s\n", numToLettered(numberColumn-1), rowColMatches["row"])
		} else if letterMatches, ok := getMatches(letterRegex, line); ok {
			letteredColumn := letteredToNum(letterMatches["col"])
			fmt.Printf("R%sC%d\n", letterMatches["row"], letteredColumn)
		} else {
			continue
		}
	}
}

// https://codeforces.com/problemset/problem/1/B

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"math"
	"os"
	"regexp"
	"strconv"
	"strings"
)

// matching
// ----------------

var letterRegex = regexp.MustCompile(`^(?P<col>[A-Z]+)(?P<row>[0-9]+)$`)
var rowColRegex = regexp.MustCompile(`^R(?P<row>[0-9]+)C(?P<col>[0-9]+)$`)

func getMatches(regex *regexp.Regexp, text string) (map[string]string, bool) {
	matches := make(map[string]string)

	match := regex.FindStringSubmatch(text)
	if match == nil {
		return matches, false
	}

	for matchIdx, matchName := range regex.SubexpNames() {
		if len(matchName) > 0 && matchIdx >= 0 && matchIdx < len(match) {
			matches[matchName] = match[matchIdx]
		}
	}

	return matches, true
}

// conversion
// ----------------

func letteredToNum(letteredNumber string) int {
	return charactersToNum([]byte(strings.ToLower(letteredNumber)))
}

func charactersToNum(characters []byte) int {
	if len(characters) == 0 {
		return 0
	}

	next, rest := characters[0], characters[1:]
	placementInt := int(math.Pow(26, float64(len(rest))))
	nextInt := int(next) - int('a') + 1

	return placementInt*nextInt + charactersToNum(rest)
}

func numToLetter(number int) (byte, int) {
	quotient := number / 26
	remainder := number % 26
	return byte(remainder + int('a') - 1), quotient
}

func numToLettered(number int) string {
	var buffer bytes.Buffer

	letter, quotient := byte(0), number
	for {
		if quotient <= 0 {
			break
		}
		letter, quotient = numToLetter(quotient)
		buffer.WriteByte(letter)
	}

	return strings.ToUpper(buffer.String())
}

// main
// ----------------

func main() {
	var totalCoordinates int

	_, err := fmt.Scanf("%d", &totalCoordinates)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	reader := bufio.NewReader(os.Stdin)
	for coordinateIdx := 0; coordinateIdx < totalCoordinates; coordinateIdx++ {
		line, _ := reader.ReadString('\n')
		line = strings.TrimSpace(line)

		if letterMatches, ok := getMatches(letterRegex, line); ok {
			letteredColumn := letteredToNum(letterMatches["col"])
			fmt.Printf("R%sC%d\n", letterMatches["row"], letteredColumn)
		} else if rowColMatches, ok := getMatches(rowColRegex, line); ok {
			numberColumn, _ := strconv.Atoi(rowColMatches["col"])
			fmt.Printf("%s%s\n", numToLettered(numberColumn), rowColMatches["row"])
		} else {
			fmt.Println("No match")
		}
	}
}

package main

import "fmt"
import "log"
import "regexp"

func main() {
	var n int;
	args, err := fmt.Scan(&n);
	if err != nil {
		log.Fatal(err);
	}
	if args != 1 {
		log.Fatal("invalid n: ", args);
	}

	re, err := regexp.Compile("R([0-9]+)C([0-9]+)");
	if err != nil {
		log.Fatal(err);
	}
	re2, err := regexp.Compile("([A-Z]+)([0-9]+)");
	if err != nil {
		log.Fatal(err);
	}

	for i := 0; i < n; i++ {
		var s string;
		args, err = fmt.Scan(&s);
		if err != nil {
			log.Fatal(err);
		}
		if args != 1 {
			log.Fatal("missing string?", args);
		}

		r := re.FindStringSubmatch(s)
		if r == nil {
			r := re2.FindStringSubmatch(s);
			if r == nil {
				log.Fatal("didn't match re2");
			}
			alpha_to_rc(r[1], r[2]);
		} else {
			rc_to_alpha(r[1], r[2]);
		}
	}
}

func alpha_to_rc(scol, srow string) {
	var col rune;

	for i, c := range scol {
		col *= 26;
		if i == 0 {
			col += c - 'A' + 1;
		} else {
			col += c - 'A';
		}
	}
	fmt.Printf("R%sC%d\n", srow, col+1);
}

func rc_to_alpha(s_row, s_col string) {
	var row, col int;
	fmt.Sscan(s_row, &row);
	fmt.Sscan(s_col, &col);

	fmt.Printf("%s%d\n", col_to_alpha(col, ""), row);
}

func col_to_alpha(col int, s string) string {
	col -= 1

	if col < 26 {
		return s + fmt.Sprintf("%c", 'A' + col);
	}
	if col < 27*26 {
		return col_to_alpha(col / 26, s) + fmt.Sprintf("%c", 'A' + (col % 26));
	}
	if col < 27*26*26 {
		return col_to_alpha(col / 26, s) + fmt.Sprintf("%c", 'A' + (col % 26));
	}
	if col < 27*26*26*26 {
		return col_to_alpha(col / 26, s) + fmt.Sprintf("%c", 'A' + (col % 26));
	}
	if col < 27*26*26*26*26 {
		return col_to_alpha(col / 26, s) + fmt.Sprintf("%c", 'A' + (col % 26));
	}
	return "TOOBIG"
}

package main

import (
    "fmt"
    "io"
    "unicode"
)

func process(coordinate string) {
    column := 0
    row := 0

    length := len(coordinate)

    k := 1
    if rune(coordinate[0]) != 'R' {
        k = length
    } else {
        for k < length && unicode.IsNumber(rune(coordinate[k])) {
            k += 1
        }
    }

    if k == length {
        k = 0
        for unicode.IsLetter(rune(coordinate[k])) {
            column = column * 26 + int(coordinate[k] - 64)
            k += 1
        }
        for k < length {
            row = row * 10 + int(coordinate[k] - 48)
            k += 1
        }

        fmt.Printf("R%dC%d\n", row, column)
    } else {
        k = 1
        for unicode.IsNumber(rune(coordinate[k])) {
            row = row * 10 + int(coordinate[k] - 48)
            k += 1
        }
        k += 1
        for k < length {
            column = column * 10 + int(coordinate[k] - 48)
            k += 1
        }

        s := make([]string, 0)

        var r int
        for column != 0 {
            r = column % 26
            column = column / 26
            if r == 0 {
                s = append(s, "Z")
                column -= 1
            } else {
                s = append(s, string(r + 64))
            }
        }

        for i := len(s) - 1; i >= 0; i-- {
            fmt.Print(s[i])
        }
        fmt.Println(row)
    }
}

func main() {
    var testCases int

    var coordinate string

    for {
        _, err := fmt.Scan(&testCases)
        if err == io.EOF {
            break
        }
        for i := 0; i < testCases; i++ {
            fmt.Scan(&coordinate)
            process(coordinate)
        }
    }
}

package main

import (
	"bytes"
	"fmt"
	"strconv"
)

func rc2bc(r, c int) {
	var bc int
	var buffer bytes.Buffer

	for c > 26 {
		bc = (c - 1) % 26
		c /= 26
		b := byte('A' + bc)
		buffer.WriteByte(b)
	}
	if c != 0 {
		bc = (c - 1) % 26
		b := byte('A' + bc)
		buffer.WriteByte(b)
	}
	str := buffer.String()
	l := len(str)
	for i := 0; i < l; i++ {
		fmt.Printf("%c", str[l-1-i])
	}
	fmt.Printf("%d\n", r)
}

func bc2rc(r int, bc string) {
	fmt.Printf("%c%d", 'R', r)

	c := 0
	l := len(bc)

	for i, p := 0, 1; i < l; i, p = i+1, p*26 {
		c += int(bc[l-1-i]-'A'+1) * p
	}
	fmt.Printf("%c%d\n", 'C', c)
}

func main() {
	var n int
	var input, bc string
	var rc_system bool
	var r, c int

	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%s\n", &input)

		rc_system = false
		if input[0] == 'R' && input[1] <= '9' && input[1] >= '0' {
			for j := 2; j < len(input)-1; j++ {
				if input[j] == 'C' {
					rc_system = true
					r, _ = strconv.Atoi(input[1:j])
					c, _ = strconv.Atoi(input[j+1:])
					break
				}
			}
		}
		if !rc_system {
			for j := 1; j < len(input); j++ {
				if input[j] <= '9' && input[j] >= '0' {
					r, _ = strconv.Atoi(input[j:])
					bc = input[0:j]
					break
				}
			}
		}

		if rc_system {
			rc2bc(r, c)
			//fmt.Printf("%v:%d,%d\n", rc_system, r, c)
		} else {
			bc2rc(r, bc)
			//fmt.Printf("%v:%d,%s\n", rc_system, r, bc)
		}

	}
}

package main

import (
	"bytes"
	"fmt"
	"strconv"
)

func rc2bc(r, c int) {
	var bc int
	var buffer bytes.Buffer
	for c > 26 {
		bc = c % 26
		c /= 26
		b := byte('A' + bc - 1)
		buffer.WriteByte(b)
	}
	if c != 0 {
		bc = c % 26
		c /= 26
		b := byte('A' + bc - 1)
		buffer.WriteByte(b)
	}
	str := buffer.String()
	l := len(str)
	for i := 0; i < l; i++ {
		fmt.Printf("%c", str[l-1-i])
	}
	fmt.Printf("%d\n", r)
}

func bc2rc(r int, bc string) {
	fmt.Printf("%c%d", 'R', r)

	c := 0
	l := len(bc)

	for i, p := 0, 1; i < l; i, p = i+1, p*26 {
		c += int(bc[l-1-i]-'A'+1) * p
	}
	fmt.Printf("%c%d\n", 'C', c)
}

func main() {
	var n int
	var input, bc string
	var rc_system bool
	var r, c int

	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%s\n", &input)

		rc_system = false
		if input[0] == 'R' && input[1] <= '9' && input[1] >= '0' {
			for j := 2; j < len(input)-1; j++ {
				if input[j] == 'C' {
					rc_system = true
					r, _ = strconv.Atoi(input[1:j])
					c, _ = strconv.Atoi(input[j+1:])
					break
				}
			}
		}
		if !rc_system {
			for j := 1; j < len(input); j++ {
				if input[j] <= '9' && input[j] >= '0' {
					r, _ = strconv.Atoi(input[j:])
					bc = input[0:j]
					break
				}
			}
		}

		if rc_system {
			rc2bc(r, c)
			//fmt.Printf("%v:%d,%d\n", rc_system, r, c)
		} else {
			bc2rc(r, bc)
			//fmt.Printf("%v:%d,%s\n", rc_system, r, bc)
		}

	}
}

package main

import "fmt"
import "os"
import "bufio"
import "strconv"
import "regexp"

// convert from RxCy to <col><row> letter number system
func convertToCoord(row string, col string) string {
	cInt, _ := strconv.Atoi(col)
	return toBase26(cInt) + row
}

// convert from <col><row> letter number system to RxCy system
func convertToRC(column string, row string) string {
	return "R" + row + "C" + fromBase26(column)
}

// convert a number like 75 to base 26 using A-Z as characters
func toBase26(num int) string {
	ans := ""
	for num != 0 {
		rem := num % 26
		num = num / 26
		ans = string('A'-1+rem) + ans
	}
	return ans
}

func fromBase26(str string) string {
	v := 0
	multiplicand := 1
	for idx := len(str) - 1; idx >= 0; idx-- {
		temp := int(str[idx] - 'A' + 1)
		v += (temp * multiplicand)
		multiplicand *= 26
	}
	return strconv.Itoa(v)
}

func main() {
	rcRegexp := regexp.MustCompile(`^R(?P<Row>[[:digit:]]+)C(?P<Column>[[:digit:]]+)$`)
	coordRegexp := regexp.MustCompile(`^(?P<Column>[[:upper:]]+)(?P<Row>[[:digit:]]+)$`)

	s := bufio.NewScanner(os.Stdin)
	s.Scan()
	val, _ := strconv.Atoi(s.Text())
	//fmt.Println("Reading", val, "values")

	for i := 0; i < val; i++ {
		s.Scan()
		coord := s.Text()

		isRc := rcRegexp.FindStringSubmatch(coord)
		isCoord := coordRegexp.FindStringSubmatch(coord)

		if len(isRc) > 0 {
			fmt.Println(convertToCoord(isRc[1], isRc[2]))
		} else if len(isCoord) > 0 {
			fmt.Println(convertToRC(isCoord[1], isCoord[2]))
		}
	}
}

package main

import (
    "fmt"
    "bufio"
    "os"
    "strconv"
)

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    writer := bufio.NewWriter(os.Stdout)
    var n int
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        scanner.Scan()
        s := scanner.Text()
        iR, iC := -1, -1
        for in, v := range s {
            if v == 'R' { iR = in }
            if v == 'C' { iC = in }
        }
        if (iR != -1) && (iC != -1) && ((iR+1) != iC) {
            r, c, in := 0, 0, 1
            for ; s[in] != 'C'; in++ {
                r = (r*10) + int(s[in]-'0')
            }
            for in++; in < len(s); in++ {
                c = (c*10) + int(s[in]-'0')
            }
            col, row := "", strconv.Itoa(r)
            for c > 0 {
                a := (c-1)%26
                col = string(rune(a+'A')) + col
                c /= 26
            }
            writer.WriteString(col+row+"\n")
        } else {
            col, row := 0, ""
            for _, v := range s {
                if (v >= 'A') && (v <= 'Z') {
                    col = (col*26) + int(v-'A'+1)
                } else {
                    row += string(v)
                }
            }
            writer.WriteString("R"+row+"C"+strconv.Itoa(col)+"\n")
        }
    }
    writer.Flush()
}

package main

import (
    "fmt"
    "bufio"
    "os"
    "strconv"
)

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    writer := bufio.NewWriter(os.Stdout)
    var n int
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        for scanner.Scan() {
            if scanner.Text() != "" { break }
        }
        s := scanner.Text()
        iR, iC := -1, -1
        for in, v := range s {
            if v == 'R' { iR = in }
            if v == 'C' { iC = in }
        }
        if (iR != -1) && (iC != -1) && ((iR+1) != iC) {
            r, c, in := 0, 0, 1
            for ; s[in] != 'C'; in++ {
                r = (r*10) + int(s[in]-'0')
            }
            for in++; in < len(s); in++ {
                c = (c*10) + int(s[in]-'0')
            }
            col, row := "", strconv.Itoa(r)
            for c > 0 {
                a := (c-1)%26
                col = string(rune(a+'A')) + col
                c /= 26
            }
            writer.WriteString(col+row+"\n")
        } else {
            col, row := 0, ""
            for _, v := range s {
                if (v >= 'A') && (v <= 'Z') {
                    col = (col*26) + int(v-'A'+1)
                } else {
                    row += string(v)
                }
            }
            writer.WriteString("R"+row+"C"+strconv.Itoa(col)+"\n")
        }
    }
    writer.Flush()
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"regexp"
	"strconv"
	"strings"
)

var AZtoY = map[string]int{}

func isRXCY(coor string) bool {
	match, _ := regexp.MatchString("^R[0-9]?C", coor)
	return match
}

func YtoAZ(y int) string {
	var col string
	for y > 0 {
		if y%26 == 0 {
			y = y/26 - 1
			col = "Z" + col
			continue
		}
		col = string(rune(64+y%26)) + col
		y = y / 26
	}
	return col

	// Recursion version
	// if y%26 == 0 {
	// 	y = y/26 - 1
	// 	return YtoAZ(y) + "Z"
	// } else if y < 26 {
	// 	return string(rune(64 + y))
	// }
	// return YtoAZ(y/26) + YtoAZ(y%26)
}

func RXCYtoExcel(coor string) string {
	cIndex := strings.Index(coor, "C")
	x := coor[1:cIndex]
	y, _ := strconv.Atoi(coor[cIndex+1:])

	return YtoAZ(y) + x
}

func ExceltoRXCY(coor string) string {
	index := regexp.MustCompile(`[0-9]`).FindIndex([]byte(coor))
	col := coor[:index[0]]
	row := coor[index[0]:]

	rxc := "R" + row + "C"

	var y int
	pow := 1
	for i := len(col); i > 0; i-- {
		y = y + AZtoY[col[i-1:i]]*pow
		pow = pow * 26
	}

	yStr := strconv.Itoa(y)
	return rxc + yStr
}

func main() {
	for i := 1; i <= 26; i++ {
		AZtoY[string(rune(64+i))] = i
	}
	lineReader := bufio.NewReader(os.Stdin)
	input, _ := lineReader.ReadString('\n')
	drop := 1
	if input[len(input)-2] == '\r' {
		drop = 2
	}
	n, _ := strconv.Atoi(input[0 : len(input)-drop])

	var output string

	for i := 0; i < n; i++ {
		input, _ := lineReader.ReadString('\n')
		drop := 1
		if input[len(input)-2] == '\r' {
			drop = 2
		}
		input = input[0 : len(input)-drop]
		if isRXCY(input) {
			output = output + RXCYtoExcel(input)
		} else {
			output = output + ExceltoRXCY(input)
		}
		output = output + "\n"
	}
	fmt.Print(output)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"regexp"
	"strconv"
	"strings"
)

var AZtoY = map[string]int{}

func isRXCY(coor string) bool {
	match, _ := regexp.MatchString("^R[0-9]", coor)
	return match
}

func YtoAZ(y int) string {
	var col string
	for y > 0 {
		if y%26 == 0 {
			y = y/26 - 1
			col = "Z" + col
			continue
		}
		col = string(rune(64+y%26)) + col
		y = y / 26
	}
	return col

	// Recursion version
	// if y%26 == 0 {
	// 	y = y/26 - 1
	// 	return YtoAZ(y) + "Z"
	// } else if y < 26 {
	// 	return string(rune(64 + y))
	// }
	// return YtoAZ(y/26) + YtoAZ(y%26)
}

func RXCYtoExcel(coor string) string {
	cIndex := strings.Index(coor, "C")
	x := coor[1:cIndex]
	y, _ := strconv.Atoi(coor[cIndex+1:])

	return YtoAZ(y) + x
}

func ExceltoRXCY(coor string) string {
	index := regexp.MustCompile(`[0-9]`).FindIndex([]byte(coor))
	col := coor[:index[0]]
	row := coor[index[0]:]

	rxc := "R" + row + "C"

	var y int
	pow := 1
	for i := len(col); i > 0; i-- {
		y = y + AZtoY[col[i-1:i]]*pow
		pow = pow * 26
	}

	yStr := strconv.Itoa(y)
	return rxc + yStr
}

func main() {
	for i := 1; i <= 26; i++ {
		AZtoY[string(rune(64+i))] = i
	}
	lineReader := bufio.NewReader(os.Stdin)
	input, _ := lineReader.ReadString('\n')
	n, _ := strconv.Atoi(input[0 : len(input)-1])

	var output string

	for i := 0; i < n; i++ {
		input, _ := lineReader.ReadString('\n')
		input = input[0 : len(input)-1]
		if isRXCY(input) {
			output = output + RXCYtoExcel(input)
		} else {
			output = output + ExceltoRXCY(input)
		}
		output = output + "\n"
	}
	fmt.Print(output)
}

package main

import (
	"fmt"
	"strconv"
)

func main() {
	var cases int64
	fmt.Scan(&cases)
	for i := int64(0); i < cases; i++ {
		var str string
		fmt.Scan(&str)
		intstr := ""
		isAnother := false
		columns, rows := "", ""
		for i := len(str) - 1; i >= 0; i-- {
			if str[i] >= '0' && str[i] <= '9' {
				intstr = str[i:i+1] + intstr
				continue
			}
			if str[i] == 'C' {
				if str[0] == 'R' && str[1] >= '0' && str[1] <= '9' && i > 1 {
					isAnother = true
					columns = intstr
					rows = str[1:i]
					break
				}
			}
			rows = intstr
			columns = str[0:i+1]
			break
		}
		// fmt.Println(rows, columns, intstr)
		if isAnother { // R23C55 --> BC23
			columns = intConvertAZ(columns)
			fmt.Println(columns + rows)
		} else { // BC23 --> R23C55
			columns = AZConvertInt(columns)
			fmt.Println("R" + rows + "C" + columns)
		}
	}
}

func intConvertAZ(str string) string {
	number := 0
	for i := 0; i < len(str); i++ {
		number = number*10 + int(str[i]-'0')
	}
	result := ""
	// fmt.Println(number)
	for number >= 26 {
		if number == 26 {
			result = "Z" + result
			number = 0
			break
		}
		left := number % 26
		number = number / 26
		char := 'A' + left - 1
		result = string(char) + result
	}
	if number > 0 { // 55 = 26 * 2 + 3
		char := 'A' + byte(number - 1)
		// fmt.Println(result)
		result = string([]byte{char}) + result
		// fmt.Println(char, result)
	}
	// fmt.Println(str, result)
	return result
}

func AZConvertInt(str string) string {
	number := 0
	for i := 0; i < len(str); i++ {
		temp := str[i] - 'A' + 1
		number = number*26 + int(temp)
	}
	// fmt.Println(str, number)
	return strconv.Itoa(number)
}

package main

import (
	"fmt"
	"strconv"
)

func main() {
	var cases int64
	fmt.Scan(&cases)
	for i := int64(0); i < cases; i++ {
		var str string
		fmt.Scan(&str)
		intstr := ""
		isAnother := false
		columns, rows := "", ""
		for i := len(str) - 1; i >= 0; i-- {
			if str[i] >= '0' && str[i] <= '9' {
				intstr = str[i:i+1] + intstr
				continue
			}
			if str[i] == 'C' {
				if str[0] == 'R' && str[1] > '0' && str[1] < '9' && i > 1 {
					isAnother = true
					columns = intstr
					rows = str[1:i]
					break
				}
			}
			columns = intstr
			rows = str[0:i+1]
			break
		}
		// fmt.Println(rows, columns, intstr)
		if isAnother { // R23C55 --> BC23
			columns = intConvertAZ(columns)
			fmt.Println(columns + rows)
		} else { // BC23 --> R23C55
			rows = AZConvertInt(rows)
			fmt.Println("R" + rows + "C" + intstr)
		}
	}
}

func intConvertAZ(str string) string {
	number := 0
	for i := len(str) - 1; i >= 0; i-- {
		number = number*10 + int(str[i]-'0')
	}
	result := ""
	for number >= 26 {
		if number == 26 {
			result = "Z" + result
			number = 0
			break
		}
		left := number % 26
		number = number / 26
		char := 'A' + left - 1
		result = string(char) + result
	}
	if number > 0 { // 55 = 26 * 2 + 3
		char := 'A' + number - 1
		result = string(char) + result
	}
	// fmt.Println(str, result)
	return result
}

func AZConvertInt(str string) string {
	number := 0
	for i := 0; i < len(str); i++ {
		temp := str[i] - 'A' + 1
		number = number*26 + int(temp)
	}
	// fmt.Println(str, number)
	return strconv.Itoa(number)
}

package main

import (
	"fmt"
	"strconv"
)

func main() {
	var cases int64
	fmt.Scan(&cases)
	for i := int64(0); i < cases; i++ {
		var str string
		fmt.Scan(&str)
		intstr := ""
		isAnother := false
		columns, rows := "", ""
		for i := len(str) - 1; i >= 0; i-- {
			if str[i] >= '0' && str[i] <= '9' {
				intstr = str[i:i+1] + intstr
				continue
			}
			if str[i] == 'C' {
				if str[0] == 'R' && str[1] >= '0' && str[1] <= '9' && i > 1 {
					isAnother = true
					columns = intstr
					rows = str[1:i]
					break
				}
			}
			rows = intstr
			columns = str[0:i+1]
			break
		}
		// fmt.Println(rows, columns, intstr)
		if isAnother { // R23C55 --> BC23
			columns = intConvertAZ(columns)
			fmt.Println(columns + rows)
		} else { // BC23 --> R23C55
			columns = AZConvertInt(columns)
			fmt.Println("R" + rows + "C" + columns)
		}
	}
}

func intConvertAZ(str string) string {
	number := 0
	for i := 0; i < len(str); i++ {
		number = number*10 + int(str[i]-'0')
	}
	result := ""
	// fmt.Println(number)
	for number >= 26 {
		left := number % 26
		char := 0
		if left == 0 {
			char = 'Z'
		} else {
			char = 'A' + left - 1
		}
		number = number / 26
		// fmt.Println(left, number, char)
		result = string(char) + result
	}
	if number > 0 { // 55 = 26 * 2 + 3
		char := 'A' + byte(number - 1)
		// fmt.Println(result)
		result = string([]byte{char}) + result
		// fmt.Println(char, result)
	}
	// fmt.Println(str, result)
	return result
}

func AZConvertInt(str string) string {
	number := 0
	for i := 0; i < len(str); i++ {
		temp := str[i] - 'A' + 1
		number = number*26 + int(temp)
	}
	// fmt.Println(str, number)
	return strconv.Itoa(number)
}

package main

import (
	"fmt"
	"strconv"
)

func main() {
	var cases int64
	fmt.Scan(&cases)
	for i := int64(0); i < cases; i++ {
		var str string
		fmt.Scan(&str)
		intstr := ""
		isAnother := false
		columns, rows := "", ""
		for i := len(str) - 1; i >= 0; i-- {
			if str[i] >= '0' && str[i] <= '9' {
				intstr = str[i:i+1] + intstr
				continue
			}
			if str[i] == 'C' {
				if str[0] == 'R' && str[1] > '0' && str[1] < '9' && i > 1 {
					isAnother = true
					columns = intstr
					rows = str[1:i]
					break
				}
			}
			rows = intstr
			columns = str[0:i+1]
			break
		}
		// fmt.Println(rows, columns, intstr)
		if isAnother { // R23C55 --> BC23
			columns = intConvertAZ(columns)
			fmt.Println(columns + rows)
		} else { // BC23 --> R23C55
			columns = AZConvertInt(columns)
			fmt.Println("R" + rows + "C" + columns)
		}
	}
}

func intConvertAZ(str string) string {
	number := 0
	for i := len(str) - 1; i >= 0; i-- {
		number = number*10 + int(str[i]-'0')
	}
	result := ""
	for number >= 26 {
		if number == 26 {
			result = "Z" + result
			number = 0
			break
		}
		left := number % 26
		number = number / 26
		char := 'A' + left - 1
		result = string(char) + result
	}
	if number > 0 { // 55 = 26 * 2 + 3
		char := 'A' + number - 1
		result = string(char) + result
	}
	// fmt.Println(str, result)
	return result
}

func AZConvertInt(str string) string {
	number := 0
	for i := 0; i < len(str); i++ {
		temp := str[i] - 'A' + 1
		number = number*26 + int(temp)
	}
	// fmt.Println(str, number)
	return strconv.Itoa(number)
}