/*
B. Spreadsheets
time limit per test10 seconds
memory limit per test64 megabytes
inputstandard input
outputstandard output
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.

Input
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 .

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

Sample test(s)
input
2
R23C55
BC23
output
BC23
R23C55
*/

#include <stdio.h>

#define MAX_SIZE 32

const int radix = 26;

void print_column(int col)
{
	if(col--)
	{
		print_column(col / radix);
		putchar((col % radix) + 'A');
	}
}

int main(void)
{
	int coordinates;

	scanf("%d", &coordinates);

	while(coordinates--)
	{
		char numbers[MAX_SIZE];

		scanf("%s", numbers);

		//In RxCx case
		if(sscanf(numbers, "R%dC%d", &raw, &column) == 2)
		{
			int raw, column;

			print_column(column);
			printf("%d\n", raw);
		}
		//In BCxx case
		else
		{
			char *raw = numbers;
			int column;

			for(column = 0; *raw >= 'A'; ++raw)
				column = column * radix + (*raw ^ 64);

			printf("R%sC%d\n", raw, column);
		}
	}

	return 0;
}


/*
B. Spreadsheets
time limit per test10 seconds
memory limit per test64 megabytes
inputstandard input
outputstandard output
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.

Input
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 .

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

Sample test(s)
input
2
R23C55
BC23
output
BC23
R23C55
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_SIZE 32

void numeration_short_to_long(char numbers[MAX_SIZE], char convert_number[MAX_SIZE]);
void numeration_long_to_short(char numbers[MAX_SIZE], char convert_number[MAX_SIZE]);

int main(void)
{
	int coordinates;
	int i = 0;

	scanf("%d", &coordinates);
	char convert_numbers[coordinates][MAX_SIZE];

	for(i = 0; i < coordinates; ++i)
	{
		char numbers[MAX_SIZE];

		scanf("%s", numbers);

		if(numbers[0] == 'R')
			numeration_long_to_short(numbers, convert_numbers[i]);
		else
			numeration_short_to_long(numbers, convert_numbers[i]);
	}

	for(i = 0; i < coordinates; ++i)
		printf("%s\n", convert_numbers[i]);

	return 0;
}

void numeration_short_to_long(char numbers[], char convert_number[])
{
	char keys[] = "1234567890";
	char pch_numbers[2][MAX_SIZE];
	int int_position = 0;
	int column = 0;
	int col_size = 0;
	int radix = 26;

	int_position = strcspn(numbers, keys);

	//extract column number
	strncpy(pch_numbers[1], numbers, int_position);
	pch_numbers[1][int_position] = '\0';

	//extract raw number
	strcpy(pch_numbers[0], &numbers[int_position]);

	col_size = strlen(pch_numbers[1]);

	int i;
	for(i = col_size-2; i >= 0; --i)
	{
		column += radix * ((int)pch_numbers[1][i] - 64);
		radix *= radix;
	}

	column += ((int)pch_numbers[1][col_size-1] - 64);
	char tmp_col[MAX_SIZE];
	sprintf(tmp_col, "%d", column);

	strcpy(convert_number, "R");
	strcat(convert_number, pch_numbers[0]);
	strcat(convert_number, "C");
	strcat(convert_number, tmp_col);
}

void numeration_long_to_short(char numbers[], char convert_number[])
{
	int column = 0;
	int col_size = 0;
	int i;
	int radix = 26;
	char *pch;
	char pch_numbers[2][MAX_SIZE];
	char tmp_col[MAX_SIZE][2];

	//extract raw number
	pch = strtok(numbers, "RC");
	strcpy(pch_numbers[0], pch);

	//extract column number
	pch = strtok(NULL, "RC");
	strcpy(pch_numbers[1], pch);

	column = atoi(pch_numbers[1]);

	while(column > radix)
	{
		int residue = column % radix;

		if(residue == 0)
		{
			sprintf(tmp_col[col_size], "%c", 'Z');
			column /= radix;
			--column;
		}
		else
		{
			sprintf(tmp_col[col_size], "%c", residue + 64);
			column /= radix;
		}

		++col_size;
		if(column / radix < radix) break;
	}
	sprintf(tmp_col[col_size++], "%c", (column/radix) + 64);

	//reverse to get the real column
	strcpy(convert_number, tmp_col[col_size-1]);
	for(i = col_size-2; i >= 0; --i)
		strcat(convert_number, tmp_col[i]);

	strcat(convert_number, pch_numbers[0]);
}


/*
B. Spreadsheets
time limit per test10 seconds
memory limit per test64 megabytes
inputstandard input
outputstandard output
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.

Input
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 .

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

Sample test(s)
input
2
R23C55
BC23
output
BC23
R23C55
*/

#include <stdio.h>
#include <string.h>

#define MAX_SIZE 32

const int radix = 26;

int main(void)
{
	int coordinates;

	scanf("%d", &coordinates);

	while(coordinates--)
	{
		char numbers[MAX_SIZE];
		int raw, column;

		scanf("%s", numbers);

		//in RxCx case
		if(sscanf(numbers, "R%dC%d", &raw, &column) == 2)
		{
			char tmp_col[MAX_SIZE];
			int i = 0;

			//convert column
			while(column)
			{
				tmp_col[i++] = ((column-1) % radix) + 'A';
				column = (column-1) / radix;
			}
			tmp_col[i] = '\0';

			//print column
			for(i = strlen(tmp_col)-1; i >= 0; --i)
				printf("%c", tmp_col[i]);

			printf("%d\n", raw);
		}
		//in BCxx case
		else
		{
			char *raw_ptr = numbers;

			//point raw to the right position and do the convert for column
			for(column = 0; *raw_ptr >= 'A'; ++raw_ptr)
				column = column * radix + (*raw_ptr ^ 64);

			printf("R%sC%d\n", raw_ptr, column);
		}
	}

	return 0;
}


/*
B. Spreadsheets
time limit per test10 seconds
memory limit per test64 megabytes
inputstandard input
outputstandard output
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.

Input
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 .

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

Sample test(s)
input
2
R23C55
BC23
output
BC23
R23C55
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_SIZE 32

void numeration_short_to_long(char numbers[MAX_SIZE], char convert_number[MAX_SIZE]);
void numeration_long_to_short(char numbers[MAX_SIZE], char convert_number[MAX_SIZE]);

char const convert_table[26][2] = \
{
	"Z\0", "A\0", "B\0", "C\0", "D\0", "E\0", "F\0",
	"G\0", "H\0", "I\0", "J\0", "K\0", "L\0",
	"M\0", "N\0", "O\0", "P\0", "Q\0", "R\0",
	"S\0", "T\0", "U\0", "V\0", "W\0", "X\0", "Y\0"
};

int main(void)
{
	int coordinates;
	int i = 0;

	scanf("%d", &coordinates);
	char convert_numbers[coordinates][MAX_SIZE];

	for(i = 0; i < coordinates; ++i)
	{
		char numbers[MAX_SIZE];

		scanf("%s", numbers);

		if(numbers[0] == 'R')
			numeration_long_to_short(numbers, convert_numbers[i]);
		else
			numeration_short_to_long(numbers, convert_numbers[i]);
	}

	for(i = 0; i < coordinates; ++i)
		printf("%s\n", convert_numbers[i]);

	return 0;
}

void numeration_short_to_long(char numbers[], char convert_number[])
{
	char keys[] = "1234567890";
	char pch_numbers[2][MAX_SIZE];
	int int_position = 0;
	int column = 0;
	int col_size = 0;
	int i;
	int radix = 26;

	int_position = strcspn(numbers, keys);

	//extract column number
	strncpy(pch_numbers[1], numbers, int_position);
	pch_numbers[1][int_position] = '\0';

	//extract raw number
	strcpy(pch_numbers[0], &numbers[int_position]);

	col_size = strlen(pch_numbers[1]);

	for(i = col_size-2; i >= 0; --i)
	{
		column += radix * ((int)pch_numbers[1][i] - 64);
		radix *= radix;
	}

	column += ((int)pch_numbers[1][col_size-1] - 64);
	char tmp_col[MAX_SIZE];
	sprintf(tmp_col, "%d", column);

	strcpy(convert_number, "R");
	strcat(convert_number, pch_numbers[0]);
	strcat(convert_number, "C");
	strcat(convert_number, tmp_col);
}

void numeration_long_to_short(char numbers[], char convert_number[])
{
	int column = 0;
	int col_size = 1;
	int i;
	int radix = 26;
	char *pch;
	char pch_numbers[2][MAX_SIZE];
	char tmp_col[MAX_SIZE][2];

	//extract raw number
	pch = strtok(numbers, "RC");
	strcpy(pch_numbers[0], pch);

	//extract column number
	pch = strtok(NULL, "RC");
	strcpy(pch_numbers[1], pch);

	column = atoi(pch_numbers[1]);

	strcpy(tmp_col[0], convert_table[(column % radix)]);
	column /= radix;
	while(column > 0)
	{
		strcpy(tmp_col[col_size], convert_table[(column % radix)]);
		column /= radix;

		if(!strcmp(tmp_col[col_size], "Z"))
			--column;

		++col_size;
	}

	//reverse to get the real column
	strcpy(convert_number, tmp_col[col_size-1]);
	for(i = col_size-2; i >= 0; --i)
		strcat(convert_number, tmp_col[i]);

	strcat(convert_number, pch_numbers[0]);
}


/*
B. Spreadsheets
time limit per test10 seconds
memory limit per test64 megabytes
inputstandard input
outputstandard output
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.

Input
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 .

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

Sample test(s)
input
2
R23C55
BC23
output
BC23
R23C55
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_SIZE 32

void numeration_short_to_long(char numbers[MAX_SIZE], char convert_number[MAX_SIZE]);
void numeration_long_to_short(char numbers[MAX_SIZE], char convert_number[MAX_SIZE]);

char const convert_table[26][2] = \
{
	"A", "B", "C", "D", "E", "F",
	"G", "H", "I", "J", "K", "L",
	"M", "N", "O", "P", "Q", "R",
	"S", "T", "U", "V", "W", "X",
	"Y", "Z"
};

int main(void)
{
	int coordinates;
	int i = 0;

	scanf("%d", &coordinates);
	char convert_numbers[coordinates][MAX_SIZE];

	for(i = 0; i < coordinates; ++i)
	{
		char numbers[MAX_SIZE];

		scanf("%s", numbers);

		if(numbers[0] == 'R')
			numeration_long_to_short(numbers, convert_numbers[i]);
		else
			numeration_short_to_long(numbers, convert_numbers[i]);
	}

	for(i = 0; i < coordinates; ++i)
		printf("%s\n", convert_numbers[i]);

	return 0;
}

void numeration_short_to_long(char numbers[], char convert_number[])
{
	char keys[] = "1234567890";
	char pch_numbers[2][MAX_SIZE];
	int int_position = 0;
	int column = 0;
	int col_size = 0;
	int i;
	int radix = 26;

	int_position = strcspn(numbers, keys);

	//extract column number
	strncpy(pch_numbers[1], numbers, int_position);
	pch_numbers[1][int_position] = '\0';

	//extract raw number
	strcpy(pch_numbers[0], &numbers[int_position]);

	col_size = strlen(pch_numbers[1]);

	for(i = col_size-2; i >= 0; --i)
	{
		column += radix * ((int)pch_numbers[1][i] - 64);
		radix *= radix;
	}

	column += ((int)pch_numbers[1][col_size-1] - 64);
	char tmp_col[MAX_SIZE];
	sprintf(tmp_col, "%d", column);

	strcpy(convert_number, "R");
	strcat(convert_number, pch_numbers[0]);
	strcat(convert_number, "C");
	strcat(convert_number, tmp_col);
}

void numeration_long_to_short(char numbers[], char convert_number[])
{
	int column = 0;
	char *pch;
	char pch_numbers[2][MAX_SIZE];

	//extract raw number
	pch = strtok(numbers, "RC");
	strcpy(pch_numbers[0], pch);

	//extract column number
	pch = strtok(NULL, "RC");
	strcpy(pch_numbers[1], pch);

	column = atoi(pch_numbers[1]);

	if(column > 26)
	{
		strcpy(convert_number, convert_table[(column / 26) - 1]);
		strcat(convert_number, convert_table[(column % 26) - 1]);
	}
	else
		strcpy(convert_number, convert_table[(column / 26) - 1]);

	strcat(convert_number, pch_numbers[0]);
}


/*
B. Spreadsheets
time limit per test10 seconds
memory limit per test64 megabytes
inputstandard input
outputstandard output
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.

Input
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 .

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

Sample test(s)
input
2
R23C55
BC23
output
BC23
R23C55
*/

#include <stdio.h>

#define MAX_SIZE 32

const int radix = 26;

void print_column(int col)
{
	if(col--)
	{
		print_column(col / radix);
		putchar((col % radix) + 'A');
	}
}

int main(void)
{
	int coordinates;

	scanf("%d", &coordinates);

	while(coordinates--)
	{
		char numbers[MAX_SIZE];
		int raw, column;

		scanf("%s", numbers);

		//In RxCx case
		if(sscanf(numbers, "R%dC%d", &raw, &column) == 2)
		{
			print_column(column);
			printf("%d\n", raw);
		}
		//In BCxx case
		else
		{
			char *raw_ptr = numbers;

			for(column = 0; *raw_ptr >= 'A'; ++raw_ptr)
				column = column * radix + (*raw_ptr ^ 64);

			printf("R%sC%d\n", raw_ptr, column);
		}
	}

	return 0;
}


/*
B. Spreadsheets
time limit per test10 seconds
memory limit per test64 megabytes
inputstandard input
outputstandard output
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.

Input
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 .

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

Sample test(s)
input
2
R23C55
BC23
output
BC23
R23C55
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_SIZE 10

void numeration_short_to_long(char numbers[MAX_SIZE], char convert_number[MAX_SIZE]);
void numeration_long_to_short(char numbers[MAX_SIZE], char convert_number[MAX_SIZE]);

int main(void)
{
	int coordinates;
	int i = 0;

	scanf("%d", &coordinates);

	for(i = 0; i < coordinates; ++i)
	{
		char numbers[MAX_SIZE];
		char convert_numbers[MAX_SIZE];

		scanf("%s", numbers);

		if(numbers[0] == 'R')
			numeration_long_to_short(numbers, convert_numbers);
		else
			numeration_short_to_long(numbers, convert_numbers);

		printf("%s\n", convert_numbers);
	}

	return 0;
}

void numeration_short_to_long(char numbers[], char convert_number[])
{
	char keys[] = "1234567890";
	char pch_numbers[2][MAX_SIZE];
	int int_position = 0;
	int column = 0;
	int col_size = 0;
	int radix = 26;

	int_position = strcspn(numbers, keys);

	//extract column number
	strncpy(pch_numbers[1], numbers, int_position);
	pch_numbers[1][int_position] = '\0';

	//extract raw number
	strcpy(pch_numbers[0], &numbers[int_position]);

	col_size = strlen(pch_numbers[1]);

	int i;
	for(i = col_size-2; i >= 0; --i)
	{
		column += radix * ((int)pch_numbers[1][i] - 64);
		radix *= radix;
	}

	column += ((int)pch_numbers[1][col_size-1] - 64);
	char tmp_col[MAX_SIZE];
	sprintf(tmp_col, "%d", column);

	strcpy(convert_number, "R");
	strcat(convert_number, pch_numbers[0]);
	strcat(convert_number, "C");
	strcat(convert_number, tmp_col);
}

void numeration_long_to_short(char numbers[], char convert_number[])
{
	int column = 0;
	int col_size = 0;
	int i;
	int radix = 26;
	char *pch;
	char pch_numbers[2][MAX_SIZE];
	char tmp_col[MAX_SIZE][2];

	//extract raw number
	pch = strtok(numbers, "RC");
	strcpy(pch_numbers[0], pch);

	//extract column number
	pch = strtok(NULL, "RC");
	strcpy(pch_numbers[1], pch);

	column = atoi(pch_numbers[1]);

	int residue = 0;
	do{
		residue = column % radix;

		if(residue == 0)
		{
			sprintf(tmp_col[col_size], "%c", 'Z');
			column /= radix;
			--column;
		}
		else
		{
			sprintf(tmp_col[col_size], "%c", residue + 64);
			column /= radix;
		}

		++col_size;

	}while(column > 0);

	//reverse to get the real column
	strcpy(convert_number, tmp_col[col_size-1]);
	for(i = col_size-2; i >= 0; --i)
		strcat(convert_number, tmp_col[i]);

	strcat(convert_number, pch_numbers[0]);
}


/*
B. Spreadsheets
time limit per test10 seconds
memory limit per test64 megabytes
inputstandard input
outputstandard output
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.

Input
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 .

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

Sample test(s)
input
2
R23C55
BC23
output
BC23
R23C55
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_SIZE 32

void numeration_short_to_long(char numbers[MAX_SIZE], char convert_number[MAX_SIZE]);
void numeration_long_to_short(char numbers[MAX_SIZE], char convert_number[MAX_SIZE]);

char const convert_table[26][2] = \
{
	"Z\0", "A\0", "B\0", "C\0", "D\0", "E\0", "F\0",
	"G\0", "H\0", "I\0", "J\0", "K\0", "L\0",
	"M\0", "N\0", "O\0", "P\0", "Q\0", "R\0",
	"S\0", "T\0", "U\0", "V\0", "W\0", "X\0", "Y\0"
};

int main(void)
{
	int coordinates;
	int i = 0;

	scanf("%d", &coordinates);
	char convert_numbers[coordinates][MAX_SIZE];

	for(i = 0; i < coordinates; ++i)
	{
		char numbers[MAX_SIZE];

		scanf("%s", numbers);

		if(numbers[0] == 'R')
			numeration_long_to_short(numbers, convert_numbers[i]);
		else
			numeration_short_to_long(numbers, convert_numbers[i]);
	}

	for(i = 0; i < coordinates; ++i)
		printf("%s\n", convert_numbers[i]);

	return 0;
}

void numeration_short_to_long(char numbers[], char convert_number[])
{
	char keys[] = "1234567890";
	char pch_numbers[2][MAX_SIZE];
	int int_position = 0;
	int column = 0;
	int col_size = 0;
	int i;
	int radix = 26;

	int_position = strcspn(numbers, keys);

	//extract column number
	strncpy(pch_numbers[1], numbers, int_position);
	pch_numbers[1][int_position] = '\0';

	//extract raw number
	strcpy(pch_numbers[0], &numbers[int_position]);

	col_size = strlen(pch_numbers[1]);

	for(i = col_size-2; i >= 0; --i)
	{
		column += radix * ((int)pch_numbers[1][i] - 64);
		radix *= radix;
	}

	column += ((int)pch_numbers[1][col_size-1] - 64);
	char tmp_col[MAX_SIZE];
	sprintf(tmp_col, "%d", column);

	strcpy(convert_number, "R");
	strcat(convert_number, pch_numbers[0]);
	strcat(convert_number, "C");
	strcat(convert_number, tmp_col);
}

void numeration_long_to_short(char numbers[], char convert_number[])
{
	int column = 0;
	int col_size = 0;
	int i;
	int radix = 26;
	char *pch;
	char pch_numbers[2][MAX_SIZE];
	char tmp_col[MAX_SIZE][2];

	//extract raw number
	pch = strtok(numbers, "RC");
	strcpy(pch_numbers[0], pch);

	//extract column number
	pch = strtok(NULL, "RC");
	strcpy(pch_numbers[1], pch);

	column = atoi(pch_numbers[1]);
	col_size = strlen(pch_numbers[1]);

	for(i = 0; i < col_size; ++i)
	{
		strcpy(tmp_col[i], convert_table[(column % radix)]);
		column /= radix;

		if(!strcmp(tmp_col[i], "Z"))
			--column;
	}

	//reverse to get the real column
	strcpy(convert_number, tmp_col[col_size-1]);
	for(i = col_size-2; i >= 0; --i)
		strcat(convert_number, tmp_col[i]);

	strcat(convert_number, pch_numbers[0]);
}


#include <stdio.h>

int main() {
	char w[100],*p;
	long long x,y,n;
	scanf("%lld\n",&n);
	while (n) {
		scanf("%s\n",w);
		x=y=0;
		if (2==sscanf(w,"R%lldC%lld",&x,&y)&&x*y>0) {
			p=w;
			while (y>0) {
				*p=(y-1)%26+'A';
				p++;
				y/=26;
			}
			while (p>w) printf("%c",*--p);
			printf("%lli\n",x);
		} else {
			y=0;
			p=w;
			while (*p>='A') {
				y=y*26+*p-'A';
				y+=1;
				p++;
			}
			printf("R%sC%lli\n",p,y);
		}
		n--;
	}
	return 0;
}


#include <stdio.h>

int main() {
	char w[100],*p;
	long long x,y,n;
	scanf("%lld\n",&n);
	while (n) {
		scanf("%s\n",w);
		if (2==sscanf(w,"R%lldC%lld",&x,&y)&&x*y>0) {
			p=w;
			while (y) {
				*p=(y-1)%26+'A';
				p++;
				y/=27;
			}
			while (p>w) printf("%c",*--p);
			printf("%lli\n",x);
		} else {
			y=0;
			p=w;
			while (*p>='A') {
				y=y*26+*p-'A'+1;
				p++;
			}
			printf("R%sC%lli\n",p,y);
		}
		n--;
	}
	return 0;
}


#include <stdio.h>

int main() {
	char w[100],*p;
	long long x,y,n;
	scanf("%lld\n",&n);
	while (n) {
		scanf("%s\n",w);
		x=y=0;
		if (2==sscanf(w,"R%lldC%lld",&x,&y)&&x*y>0) {
			p=w;
			while (y) {
				*p=(y-1)%26+'A';
				p++;
				y/=26;
			}
			while (p>w) printf("%c",*--p);
			printf("%lli\n",x);
		} else {
			y=0;
			p=w;
			while (*p>='A') {
				y=y*26+*p-'A'+1;
				p++;
			}
			printf("R%sC%lli\n",p,y);
		}
		n--;
	}
	return 0;
}


#include <stdio.h>

int main() {
	char w[100],*p;
	long long x,y,n;
	scanf("%lld\n",&n);
	while (n) {
		scanf("%s\n",w);
		x=y=0;
		if (2==sscanf(w,"R%lldC%lld",&x,&y)&&x*y>0) {
			p=w;
			while (y>1) {
				*p=(y-1)%26+'A';
				p++;
				y/=26;
			}
			while (p>w) printf("%c",*--p);
			printf("%lli\n",x);
		} else {
			y=0;
			p=w;
			while (*p>='A') {
				y=y*26+*p-'A';
				y+=1;
				p++;
			}
			printf("R%sC%lli\n",p,y);
		}
		n--;
	}
	return 0;
}


#include <stdio.h>

int main() {
	char w[100],*p;
	long long x,y,n;
	scanf("%lld\n",&n);
	while (n) {
		scanf("%s\n",w);
		if (2==sscanf(w,"R%lldC%lld",&x,&y)&&x*y>0) {
			p=w;
			while (y) {
				*p=(y-1)%26+'A';
				p++;
				y/=26;
			}
			while (p>w) printf("%c",*--p);
			printf("%lli\n",x);
		} else {
			y=0;
			p=w;
			while (*p>='A') {
				y=y*26+*p-'A'+1;
				p++;
			}
			printf("R%sC%lli\n",p,y);
		}
		n--;
	}
	return 0;
}


#include <stdio.h>

int main() {
	char w[100],*p;
	long long x,y,n;
	scanf("%lld\n",&n);
	while (n) {
		scanf("%s\n",w);
		x=y=0;
		if (2==sscanf(w,"R%lldC%lld",&x,&y)&&x*y>0) {
			p=w;
			while (y>1) {
				*p=(y-1)%26+'A';
				p++;
				y/=26;
			}
			while (p>w) printf("%c",*--p);
			printf("%lli\n",x);
		} else {
			y=0;
			p=w;
			while (*p>='A') {
				y=y*26+*p-'A'+1;
				p++;
			}
			printf("R%sC%lli\n",p,y);
		}
		n--;
	}
	return 0;
}


#include<stdio.h>
#include<string.h>
#include<ctype.h>
int power(int x,int y)
{
    int t=1;
    for(int i=0;i<y;i++)
    {
        t = t * x;
    }
    return t;
}
int main()
{
    int t;
    char s[50];
    scanf("%d",&t);
    getchar();
    while(t--)
    {
        gets(s);
        int isLeap = 0;
        int x;
        for(int i=2;i<strlen(s);i++)
        {
            if(isupper(s[i]))
            {
                x = i;
                isLeap = 1;break;
            }
        }
        if(isdigit(s[1]) && isLeap == 1)
        {
            int sum = 0;
            for(int i=x+1;i<strlen(s);i++)
            {
                sum = sum*10+s[i]-48;
            }
            if(sum == 1)
            {
                printf("A");
                for(int i=1;i<x;i++)
                {
                    printf("%c",s[i]);
                }
                printf("\n");
            }
            else
            {
                sum--;
                int i = 0;
                while(1)
                {
                    if(sum>=power(26,i) && sum<power(26,i+1))
                    {
                        break;
                    }i++;
                }
                for(int j=0;j<i+1;j++)
                {
                    printf("%c",sum/power(26,i-j)+64);
                    sum = sum % power(26,i-j) + 1;
                }
                for(i=1;i<x;i++)
                {
                    printf("%c",s[i]);
                }
                printf("\n");
            }
        }
        else
        {
            int sum = 0;
            int i=1;
            while(1)
            {
                if(isdigit(s[i]))
                {
                    break;
                }
                i++;
            }
            printf("R");
            for(int j=i;j<strlen(s);j++)
            {
                printf("%c",s[j]);
            }
            for(int j=0;j<i;j++)
            {
                sum = sum*26+s[j]-64;
            }
            printf("C%d\n",sum);
        }
                ///�����������char��int�ǿ��Ի����ģ���Ҫ���ɣ�����ֻ���ܳ����������ط�
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<ctype.h>
int power(int x,int y)
{
    int t=1;
    for(int i=0;i<y;i++)
    {
        t = t * x;
    }
    return t;
}
int main()
{
    int t;
    char s[50],b[50];
    scanf("%d",&t);
    getchar();
    while(t--)
    {
        gets(s);
        int isLeap = 0;
        int x;
        for(int i=2;i<strlen(s);i++)
        {
            if(isupper(s[i]))
            {
                x = i;
                isLeap = 1;break;
            }
        }
        if(isdigit(s[1]) && isLeap == 1)
        {
            int sum = 0,i;
            for(int i=x+1;i<strlen(s);i++)
            {
                sum = sum*10+s[i]-48;
            }
            if(sum>=1 && sum<=26)
                i = 0;
            else if(sum>26 && sum<=26*26+26)
                i = 1;
            else if(sum>26*26+26 && sum<=26*26*26+26*26+26)
                i = 2;
            else if(sum>26*26*26+26*26+26 && sum<=26*26*26*26+26*26*26+26*26+26)
                i = 3;
            else i = 4;
            for(int j=0;j<i+1;j++)
            {
                b[j] = sum/power(26,i-j)+64;
                sum = sum % power(26,i-j);
            }
            for(int j=i;j>0;j--)
            {
                if(b[j] == '@')
                {
                    b[j-1] -= 1;
                    b[j] += 26;
                }
            }
            for(int j=0;j<=i;j++)
            {
                printf("%c",b[j]);
            }
            for(i=1;i<x;i++)
            {
                printf("%c",s[i]);
            }
            printf("\n");

        }
        else
        {
            int sum = 0;
            int i=1;
            while(1)
            {
                if(isdigit(s[i]))
                {
                    break;
                }
                i++;
            }
            printf("R");
            for(int j=i;j<strlen(s);j++)
            {
                printf("%c",s[j]);
            }
            for(int j=0;j<i;j++)
            {
                sum = sum*26+s[j]-64;
            }
            printf("C%d\n",sum);
        }
                ///�����������char��int�ǿ��Ի����ģ���Ҫ���ɣ�����ֻ���ܳ����������ط�
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<ctype.h>
int power(int x,int y)
{
    int t=1;
    for(int i=0;i<y;i++)
    {
        t = t * x;
    }
    return t;
}
int main()
{
    int t;
    char s[50],b[50];
    scanf("%d",&t);
    getchar();
    while(t--)
    {
        gets(s);
        int isLeap = 0;
        int x;
        for(int i=2;i<strlen(s);i++)
        {
            if(isupper(s[i]))
            {
                x = i;
                isLeap = 1;break;
            }
        }
        if(isdigit(s[1]) && isLeap == 1)
        {
            int sum = 0;
            for(int i=x+1;i<strlen(s);i++)
            {
                sum = sum*10+s[i]-48;
            }
            if(sum == 1)
            {
                printf("A");
                for(int i=1;i<x;i++)
                {
                    printf("%c",s[i]);
                }
                printf("\n");
            }
            else
            {
                sum--;
                int i = 0;
                while(1)
                {
                    if(sum>=power(26,i) && sum<power(26,i+1))
                    {
                        break;
                    }i++;
                }
                if(i<1)
                {
                    printf("%c",sum+65);
                }
                else
                {
                    for(int j=0;j<i+1;j++)
                    {
                        b[j] = sum/power(26,i-j)+64;
                        sum = (sum+1) % power(26,i-j);
                    }
                    for(int j=0;j<i+1;j++)
                    {
                        printf("%c",(b[j]=='@')?(b[j]+26):(b[j]));      ///�ڣ�����������  ע��Ⱥ�   ��   ==
                    }

                }
                for(i=1;i<x;i++)
                {
                    printf("%c",s[i]);
                }
                printf("\n");
            }
        }
        else
        {
            int sum = 0;
            int i=1;
            while(1)
            {
                if(isdigit(s[i]))
                {
                    break;
                }
                i++;
            }
            printf("R");
            for(int j=i;j<strlen(s);j++)
            {
                printf("%c",s[j]);
            }
            for(int j=0;j<i;j++)
            {
                sum = sum*power(26,i-j)+s[j]-64;
            }
            printf("C%d\n",sum);
        }
                ///�����������char��int�ǿ��Ի����ģ���Ҫ���ɣ�����ֻ���ܳ����������ط�
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<ctype.h>
int power(int x,int y)
{
    int t=1;
    for(int i=0;i<y;i++)
    {
        t = t * x;
    }
    return t;
}
int main()
{
    int t;
    char s[50];
    scanf("%d",&t);
    getchar();
    while(t--)
    {
        gets(s);
        int isLeap = 0;
        int x;
        for(int i=2;i<strlen(s);i++)
        {
            if(isupper(s[i]))
            {
                x = i;
                isLeap = 1;break;
            }
        }
        if(isdigit(s[1]) && isLeap == 1)
        {
            int sum = 0;
            for(int i=x+1;i<strlen(s);i++)
            {
                sum = sum*10+s[i]-48;
            }
            if(sum == 1)
            {
                printf("A");
                for(int i=1;i<x;i++)
                {
                    printf("%c",s[i]);
                }
                printf("\n");
            }
            else
            {
                int i = 0;
                while(1)
                {
                    if(sum>=power(26,i) && sum<power(26,i+1))
                    {
                        break;
                    }i++;
                }
                for(int j=0;j<i+1;j++)
                {
                    printf("%c",sum/power(26,i-j)+64);
                    sum = sum % power(26,i-j);
                }
                for(i=1;i<x;i++)
                {
                    printf("%c",s[i]);
                }
                printf("\n");
            }
        }
        else
        {
            int sum = 0;
            int i=1;
            while(1)
            {
                if(isdigit(s[i]))
                {
                    break;
                }
                i++;
            }
            printf("R");
            for(int j=i;j<strlen(s);j++)
            {
                printf("%c",s[j]);
            }
            for(int j=0;j<i;j++)
            {
                sum = sum*26+s[j]-64;
            }
            printf("C%d\n",sum);
        }
                ///�����������char��int�ǿ��Ի����ģ���Ҫ���ɣ�����ֻ���ܳ����������ط�
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<ctype.h>
int power(int x,int y)
{
    int t=1;
    for(int i=0;i<y;i++)
    {
        t = t * x;
    }
    return t;
}
int main()
{
    int t;
    char s[50],b[50];
    scanf("%d",&t);
    getchar();
    while(t--)
    {
        gets(s);
        int isLeap = 0;
        int x;
        for(int i=2;i<strlen(s);i++)
        {
            if(isupper(s[i]))
            {
                x = i;
                isLeap = 1;break;
            }
        }
        if(isdigit(s[1]) && isLeap == 1)
        {
            int sum = 0;
            for(int i=x+1;i<strlen(s);i++)
            {
                sum = sum*10+s[i]-48;
            }
            if(sum == 1)
            {
                printf("A");
                for(int i=1;i<x;i++)
                {
                    printf("%c",s[i]);
                }
                printf("\n");
            }
            else
            {
                sum--;
                int i = 0;
                while(1)
                {
                    if(sum>=power(26,i) && sum<power(26,i+1))
                    {
                        break;
                    }i++;
                }
                for(int j=0;j<i+1;j++)
                {
                    b[j] = sum/power(26,i-j)+64;
                    sum = (sum+1) % power(26,i-j);
                }
                for(int j=0;j<i+1;j++)
                {
                    printf("%c",(b[j]=='@')?(b[j]+26):(b[j]));      ///�ڣ�����������  ע��Ⱥ�   ��   ==
                }
                for(i=1;i<x;i++)
                {
                    printf("%c",s[i]);
                }
                printf("\n");
            }
        }
        else
        {
            int sum = 0;
            int i=1;
            while(1)
            {
                if(isdigit(s[i]))
                {
                    break;
                }
                i++;
            }
            printf("R");
            for(int j=i;j<strlen(s);j++)
            {
                printf("%c",s[j]);
            }
            for(int j=0;j<i;j++)
            {
                sum = sum*power(26,i-j)+s[j]-64;
            }
            printf("C%d\n",sum);
        }
                ///�����������char��int�ǿ��Ի����ģ���Ҫ���ɣ�����ֻ���ܳ����������ط�
    }
    return 0;
}


#include<stdio.h>
#include<math.h>
#include<string.h>
void func(long long int c,char x[])
          {  long long int i,p;
                   c--;
                   if(c!=0)
                  p=(long long int)(log(c)/log(26));
                   else
                p=0;
                   i=p;
                          while(i>=0)
                   {    x[i]=c%26+'A';
                           c=c/26-1;
                   i-- ;   }
                          x[p+1]='\0';
                                    }

void func1(char b[])
	 { long long int j=0;long long int i;
		 while(b[j]>='A' && b[j]<='Z')
                        { j++; }
		long long int r=0; long long int  c=0;
		 for(i=0;i<j;i++)
		 { c=b[i]-'A'+1 + (26*c); }
                      for(i=j;i<strlen(b);i++)
                           { r=b[i]-'0'+r*10; }
printf("R%lldC%lld\n",r,c);

 }

int main()
	 { long long int n,p; char s[1000000];char x[1000000];
		 scanf("%lld",&n);
		 while(n--)
 		 {  scanf("%s",s);
			 long long int i=0;
		long long int r=0;long long int c=0;
	long long int y=1;

                      if(s[0]=='R')
                          { while(s[i]!='C')
                                 i++;
			  for(p=i-1;p>0;p--)
			  { r=(s[p]-'0')*y+r;
			   y=y*10; }
                       y=1;
                          for(p=strlen(s)-1;p>i;p--)
                                  { c=(s[p]-'0')*y+c;
                                        y=y*10; }
			  func(c,x);
                          printf("%s%lld\n",x,r);

			  }
		      else
	                        func1(s);
		 }

	      	      return 0; }


#include<stdio.h>
#include<math.h>
#include<string.h>
long long int func(long long int c,char x[])
          { long long  int i;

             c--;
                            i=0;
                          while(c>=0)
                   {    x[i]=c%26+'A';
                           c=c/26-1;
                   i++ ;   }
                          x[i]='\0';
             return i;
                                    }

/*void func(long long int c,char x[])
          {  long long int i,p;
                   c--;
                 if(c!=0)
                  p=(long long int)(log(c)/log(26));
		 else
			 p=0;

                   i=p;
                          while(i>=0)
                   {    x[i]=c%26+'A';
                           c=c/26-1;
                   i-- ;   }
                          x[p+1]='\0';
                                    }
*/
void func1(char b[])
	 { long long int j=0;long long int i;
		 while(b[j]>='A' && b[j]<='Z')
                        { j++; }
		long long int r=0; long long int  c=0;
		 for(i=0;i<j;i++)
		 { c=b[i]-'A'+1 + (26*c); }
                      for(i=j;i<strlen(b);i++)
                           { r=b[i]-'0'+r*10; }
printf("R%lldC%lld\n",r,c);

 }

int main()
	 { long long int n,p; char s[1000000];char x[1000000];
		 scanf("%lld",&n);
		 while(n--)
 		 {  scanf("%s",s);
			 long long int i=0;
		long long int r=0;long long int c=0;
	long long int y=1;
		       long long int u;
                      if(s[0]=='R')
                          { while(s[i]!='C')
                                 i++;
			  for(p=i-1;p>0;p--)
			  { r=(s[p]-'0')*y+r;
			   y=y*10; }
                       y=1;
                          for(p=strlen(s)-1;p>i;p--)
                                  { c=(s[p]-'0')*y+c;
                                        y=y*10; }
			 u=func(c,x);
                         for(p=u-1;p>=0;p--)
				 printf("%c",x[p]);
			 printf("%lld\n",r);

			  }
		      else
	                        func1(s);
		 }

	      	      return 0; }


#include<stdio.h>
#include<math.h>
#include<string.h>
void func(long long int c,char x[])
          {  long long int i,p;
                   c--;
                   if(c!=0)
                  p=(long long int)(log(c)/log(26));
                   else
                p=0;
                   i=p;
                          while(i>=0)
                   {    x[i]=c%26+'A';
                           c=c/26-1;
                   i-- ;   }
                          x[p+1]='\0';
                                    }

void func1(char b[])
	 { long long int j=0;long long int i;
		 while(b[j]>='A' && b[j]<='Z')
                        { j++; }
		long long int r=0; long long int  c=0;
		 for(i=0;i<j;i++)
		 { c=b[i]-'A'+1 + (26*c); }
                      for(i=j;i<strlen(b);i++)
                           { r=b[i]-'0'+r*10; }
printf("R%lldC%lld\n",r,c);

 }

int main()
	 { long long int n,p; char s[1000000];long long int i=0; char x[1000000];
		 scanf("%lld",&n);
		 while(n--)
 		 {  scanf("%s",s);
		long long int r=0;long long int c=0;
	long long int y=1;

                      if(s[0]=='R')
                          { while(s[i]!='C')
                                 i++;
			  for(p=i-1;p>0;p--)
			  { r=(s[p]-'0')*y+r;
			   y=y*10; }
                       y=1;
                          for(p=strlen(s)-1;p>i;p--)
                                  { c=(s[p]-'0')*y+c;
                                        y=y*10; }
			  func(c,x);
                          printf("%s%lld\n",x,r);

			  }
		      else
	                        func1(s);
		   	 }

	      	      return 0; }


#include<stdio.h>
#include<math.h>
#include<string.h>
long long int func(long long int c,char x[])
          { long long  int i;

             c--;
                            i=0;
                          while(c>=0)
                   {    x[i]=c%26+'A';
                           c=c/26-1;
                   i++ ;   }
                          x[i]='\0';
             return i;
                                    }

/*void func(long long int c,char x[])
          {  long long int i,p;
                   c--;
                 if(c!=0)
                  p=(long long int)(log(c)/log(26));
		 else
			 p=0;

                   i=p;
                          while(i>=0)
                   {    x[i]=c%26+'A';
                           c=c/26-1;
                   i-- ;   }
                          x[p+1]='\0';
                                    }
*/
void func1(char b[])
	 { long long int j=0;long long int i;
		 while(b[j]>='A' && b[j]<='Z')
                        { j++; }
		long long int r=0; long long int  c=0;
		 for(i=0;i<j;i++)
		 { c=b[i]-'A'+1 + (26*c); }
                      for(i=j;i<strlen(b);i++)
                           { r=b[i]-'0'+r*10; }
printf("R%lldC%lld\n",r,c);

 }

int main()
	 { long long int n,p; char s[1000000];char x[1000000];
		 scanf("%lld",&n);
		 while(n--)
 		 {  scanf("%s",s);
			 long long int i=0;
		long long int r=0;long long int c=0;
	long long int y=1;
		       long long int u;
                           if(s[0]=='R'&& (s[1]>'Z'|| s[1]<'A'))
			      { while(s[i]!='C')
                                     i++;
				          }
                            else
	 i=strlen(s);

                      if(i<strlen(s))
                          {  for(p=i-1;p>0;p--)
			  { r=(s[p]-'0')*y+r;
			   y=y*10; }
                       y=1;
                          for(p=strlen(s)-1;p>i;p--)
                                  { c=(s[p]-'0')*y+c;
                                        y=y*10; }
			 u=func(c,x);
                         for(p=u-1;p>=0;p--)
				 printf("%c",x[p]);
			 printf("%lld\n",r);

			  }
		      else
	                        func1(s);
		 }

	      	      return 0; }


#include<stdio.h>
#include<math.h>
#include<string.h>
long long int func(long long int c,char x[])
          { long long  int i;

             c--;
                            i=0;
                          while(c>=0)
                   {    x[i]=c%26+'A';
                           c=c/26-1;
                   i++ ;   }
                          x[i]='\0';
             return i;
                                    }

/*void func(long long int c,char x[])
          {  long long int i,p;
                   c--;
                 if(c!=0)
                  p=(long long int)(log(c)/log(26));
		 else
			 p=0;

                   i=p;
                          while(i>=0)
                   {    x[i]=c%26+'A';
                           c=c/26-1;
                   i-- ;   }
                          x[p+1]='\0';
                                    }
*/
void func1(char b[])
	 { long long int j=0;long long int i;
		 while(b[j]>='A' && b[j]<='Z')
                        { j++; }
		long long int r=0; long long int  c=0;
		 for(i=0;i<j;i++)
		 { c=b[i]-'A'+1 + (26*c); }
                      for(i=j;i<strlen(b);i++)
                           { r=b[i]-'0'+r*10; }
printf("R%lldC%lld\n",r,c);

 }

int main()
	 { long long int n,p; char s[1000000];char x[1000000];
		 scanf("%lld",&n);
		 while(n--)
 		 {  scanf("%s",s);
			 long long int i=0;
		long long int r=0;long long int c=0;
	long long int y=1;
		       long long int u;
                           if(s[0]=='R')
			      { i=i+2;
				      while(s[i]!='C')
                                     i++;
			      }
                            else
	 i=strlen(s);

                      if(i<strlen(s))
                          {  for(p=i-1;p>0;p--)
			  { r=(s[p]-'0')*y+r;
			   y=y*10; }
                       y=1;
                          for(p=strlen(s)-1;p>i;p--)
                                  { c=(s[p]-'0')*y+c;
                                        y=y*10; }
			 u=func(c,x);
                         for(p=u-1;p>=0;p--)
				 printf("%c",x[p]);
			 printf("%lld\n",r);

			  }
		      else
	                        func1(s);
		 }

	      	      return 0; }


#include<stdio.h>
#include<math.h>
#include<string.h>
long long int func(long long int c,char x[])
          { long long  int i;

             c--;
                            i=0;
                          while(c>=0)
                   {    x[i]=c%26+'A';
                           c=c/26-1;
                   i++ ;   }
                          x[i]='\0';
             return i;
                                    }

/*void func(long long int c,char x[])
          {  long long int i,p;
                   c--;
                 if(c!=0)
                  p=(long long int)(log(c)/log(26));
		 else
			 p=0;

                   i=p;
                          while(i>=0)
                   {    x[i]=c%26+'A';
                           c=c/26-1;
                   i-- ;   }
                          x[p+1]='\0';
                                    }
*/
void func1(char b[])
	 { long long int j=0;long long int i;
		 while(b[j]>='A' && b[j]<='Z')
                        { j++; }
		long long int r=0; long long int  c=0;
		 for(i=0;i<j;i++)
		 { c=b[i]-'A'+1 + (26*c); }
                      for(i=j;i<strlen(b);i++)
                           { r=b[i]-'0'+r*10; }
printf("R%lldC%lld\n",r,c);

 }

int main()
	 { long long int n,p; char s[1000000];char x[1000000];
		 scanf("%lld",&n);
		 while(n--)
 		 {  scanf("%s",s);
			 long long int i=0;
		long long int r=0;long long int c=0;
	long long int y=1;
		       long long int u;
                           if(s[0]=='R'&&s[1]>'Z' && s[1]<'A')
			      { while(s[i]!='C')
                                     i++;
			      }
                            else
	 i=strlen(s);

                      if(i<strlen(s))
                          {  for(p=i-1;p>0;p--)
			  { r=(s[p]-'0')*y+r;
			   y=y*10; }
                       y=1;
                          for(p=strlen(s)-1;p>i;p--)
                                  { c=(s[p]-'0')*y+c;
                                        y=y*10; }
			 u=func(c,x);
                         for(p=u-1;p>=0;p--)
				 printf("%c",x[p]);
			 printf("%lld\n",r);

			  }
		      else
	                        func1(s);
		 }

	      	      return 0; }


#include<stdio.h>
#include<math.h>
#include<string.h>
long long int func(long long int c,char x[])
          { long long  int i;

             c--;
                            i=0;
                          while(c>=0)
                   {    x[i]=c%26+'A';
                           c=c/26-1;
                   i++ ;   }
                          x[i]='\0';
             return i;
                                    }

/*void func(long long int c,char x[])
          {  long long int i,p;
                   c--;
                 if(c!=0)
                  p=(long long int)(log(c)/log(26));
		 else
			 p=0;

                   i=p;
                          while(i>=0)
                   {    x[i]=c%26+'A';
                           c=c/26-1;
                   i-- ;   }
                          x[p+1]='\0';
                                    }
*/
void func1(char b[])
	 { long long int j=0;long long int i;
		 while(b[j]>='A' && b[j]<='Z')
                        { j++; }
		long long int r=0; long long int  c=0;
		 for(i=0;i<j;i++)
		 { c=b[i]-'A'+1 + (26*c); }
                      for(i=j;i<strlen(b);i++)
                           { r=b[i]-'0'+r*10; }
printf("R%lldC%lld\n",r,c);

 }

int main()
	 { long long int n,p; char s[1000000];char x[1000000];
		 scanf("%lld",&n);
		 while(n--)
 		 {  scanf("%s",s);
			 long long int i=0;
		long long int r=0;long long int c=0;
	long long int y=1;
		       long long int u;
                      if(s[0]=='R')
                          { while(s[i]!='C')
                                 i++;
			  for(p=i-1;p>0;p--)
			  { r=(s[p]-'0')*y+r;
			   y=y*10; }
                       y=1;
                          for(p=strlen(s)-1;p>i;p--)
                                  { c=(s[p]-'0')*y+c;
                                        y=y*10; }
			 u=func(c,x);
                         for(p=u-1;p>=0;p--)
				 printf("%c",x[p]);
			 printf("%lld",r);

			  }
		      else
	                        func1(s);
		 }

	      	      return 0; }


#include<stdio.h>
#include<math.h>
#include<string.h>
long long int func(long long int c,char x[])
          { long long  int i;

             c--;
                            i=0;
                          while(c>=0)
                   {    x[i]=c%26+'A';
                           c=c/26-1;
                   i++ ;   }
                          x[i]='\0';
             return i;
                                    }

/*void func(long long int c,char x[])
          {  long long int i,p;
                   c--;
                 if(c!=0)
                  p=(long long int)(log(c)/log(26));
		 else
			 p=0;

                   i=p;
                          while(i>=0)
                   {    x[i]=c%26+'A';
                           c=c/26-1;
                   i-- ;   }
                          x[p+1]='\0';
                                    }
*/
void func1(char b[])
	 { long long int j=0;long long int i;
		 while(b[j]>='A' && b[j]<='Z')
                        { j++; }
		long long int r=0; long long int  c=0;
		 for(i=0;i<j;i++)
		 { c=b[i]-'A'+1 + (26*c); }
                      for(i=j;i<strlen(b);i++)
                           { r=b[i]-'0'+r*10; }
printf("R%lldC%lld\n",r,c);

 }

int main()
	 { long long int n,p; char s[1000000];char x[1000000];
		 scanf("%lld",&n);
		 while(n--)
 		 {  scanf("%s",s);
			 long long int i=0;
		long long int r=0;long long int c=0;
	long long int y=1;
		       long long int u;
                           if(s[0]=='R')
			      { while(s[i]!='C')
                                     i++;
			      }
                            else
	 i=strlen(s);

                      if(i<strlen(s))
                          {  for(p=i-1;p>0;p--)
			  { r=(s[p]-'0')*y+r;
			   y=y*10; }
                       y=1;
                          for(p=strlen(s)-1;p>i;p--)
                                  { c=(s[p]-'0')*y+c;
                                        y=y*10; }
			 u=func(c,x);
                         for(p=u-1;p>=0;p--)
				 printf("%c",x[p]);
			 printf("%lld\n",r);

			  }
		      else
	                        func1(s);
		 }

	      	      return 0; }


#include<stdio.h>
#include<string.h>

typedef struct node
	{
	char ch;
	struct node *next;
	} node;

void convert0(char cell[],int len)
	{
	int i=0;
	while(!isdigit(cell[i]))
		{
		i++;
		}
	long long prod=1;
	long long columns=0;
	int j=i-1;
	printf("R");
	while(i<len)
		{
		printf("%c",cell[i]);
		i++;
		}
	printf("C");
	while(j>=0)
		{
		columns+=prod*((long long)(cell[j])-64);
		prod*=26;
		j--;
		}
	printf("%I64d\n",columns);
	}

void convert1(long long c, long long r)
	{
	node *start=NULL;
	node *temp;
	while(r>0)
		{
		temp=(node *)malloc(sizeof(node));
		if(r%26==0)
		{temp->ch='Z';
		r=r/26;
		r--;
		}
		else
		{temp->ch=(char)((r%26)+64);
		r=r/26;
		}
		temp->next=start;
		start=temp;

		}
		while(temp)
		{
		printf("%c",temp->ch);
		temp=temp->next;
		}
		printf("%I64d\n",c);
	}

int main()
	{
	char cell[16];
	int n;
	scanf("%d",&n);
	while(n--)
	{
	scanf("%s",cell);
	int len=strlen(cell);
	int count=0;
	int mode=0;
	long long c=0;
	long long r=0;
	int i=2;
	if(cell[0]=='R')
		{
		while(i<len)
			{
			if(cell[i]=='C')
				{
				mode=1;
				break;
				}
			i++;
			}
		}
	if(mode==0)
		{
		convert0(cell,len);
		}
	if(mode==1)
		{
		int j=1;
		r=0;
		c=0;

		while(j<i)
			{
			r=r*10;
			r=r + (long long)cell[j]-48;
			j++;
			}
		j++;

		while(j<len)
			{
			c=c*10;
			c=c + (long long)cell[j]-48;
			j++;
			}
		convert1(r,c);
		}
		}
	}


#include<stdio.h>
#include<string.h>

typedef struct node
	{
	char ch;
	struct node *next;
	} node;

void convert0(char cell[],int len)
	{
	int i=0;
	while(!isdigit(cell[i]))
		{
		i++;
		}
	long long prod=1;
	long long columns=0;
	int j=i-1;
	printf("R");
	while(i<len)
		{
		printf("%c",cell[i]);
		i++;
		}
	printf("C");
	while(j>=0)
		{
		columns+=prod*((long long)(cell[j])-64);
		prod*=26;
		j--;
		}
	printf("%I64d\n",columns);
	}

void convert1(long long c, long long r)
	{
	node *start=NULL;
	node *temp;
	while(r>0)
		{
		temp=(node *)malloc(sizeof(node));
		if(r%26==0)
		{temp->ch='Z';
		r=r/26;
		r--;
		}
		else
		{temp->ch=(char)((r%26)+64);
		r=r/26;
		}
		temp->next=start;
		start=temp;

		}
		while(temp)
		{
		printf("%c",temp->ch);
		temp=temp->next;
		}
		printf("%I64d\n",c);
	}

int main()
	{
	char cell[16];
	int n;
	scanf("%d",&n);
	while(n--)
	{
	scanf("%s",cell);
	int len=strlen(cell);
	int count=0;
	int mode=0;
	long long c=0;
	long long r=0;
	int i=2;
	if(cell[0]=='R')
		{
		if(isdigit(cell[1]))
		{
		while(i<len)
			{
			if(cell[i]=='C')
				{
				break;
				}
			i++;
			}
			}
		}
	if(mode==0)
		{
		convert0(cell,len);
		}
	if(mode==1)
		{
		int j=1;
		r=0;
		c=0;

		while(j<i)
			{
			r=r*10;
			r=r + (long long)cell[j]-48;
			j++;
			}
		j++;

		while(j<len)
			{
			c=c*10;
			c=c + (long long)cell[j]-48;
			j++;
			}
		convert1(r,c);
		}
		}
	}


#include<stdio.h>
#include<string.h>

typedef struct node
	{
	char ch;
	struct node *next;
	} node;

void convert0(char cell[],int len)
	{
	int i=0;
	while(!isdigit(cell[i]))
		{
		i++;
		}
	long long prod=1;
	long long columns=0;
	int j=i-1;
	printf("R");
	while(i<len)
		{
		printf("%c",cell[i]);
		i++;
		}
	printf("C");
	while(j>=0)
		{
		columns+=prod*((long long)(cell[j])-64);
		prod*=26;
		j--;
		}
	printf("%I64d\n",columns);
	}

void convert1(long long c, long long r)
	{
	node *start=NULL;
	node *temp;
	while(r>0)
		{
		temp=(node *)malloc(sizeof(node));
		if(r%26==0)
		{temp->ch='Z';
		r=r/26;
		r--;
		}
		else
		{temp->ch=(char)((r%26)+64);
		r=r/26;
		}
		temp->next=start;
		start=temp;

		}
		while(temp)
		{
		printf("%c",temp->ch);
		temp=temp->next;
		}
		printf("%I64d\n",c);
	}

int main()
	{
	char cell[16];
	int n;
	scanf("%d",&n);
	while(n--)
	{
	scanf("%s",cell);
	int len=strlen(cell);
	int count=0;
	int mode=0;
	long long c=0;
	long long r=0;
	int i=2;
	if(cell[0]=='R')
		{
		while(i<len && isdigit(cell[i]))
			{
			i++;
			}
		if(i<len)
			{
			mode=1;
			}
		}
	if(mode==0)
		{
		convert0(cell,len);
		}
	if(mode==1)
		{
		int j=1;
		r=0;
		c=0;

		while(j<i)
			{
			r=r*10;
			r=r + (long long)cell[j]-48;
			j++;
			}
		j++;

		while(j<len)
			{
			c=c*10;
			c=c + (long long)cell[j]-48;
			j++;
			}
		convert1(r,c);
		}
		}
	}


#include<stdio.h>
#include<string.h>

typedef struct node
	{
	char ch;
	struct node *next;
	} node;

void convert0(char cell[],int len)
	{
	int i=0;
	while(!isdigit(cell[i]))
		{
		i++;
		}
	long long prod=1;
	long long columns=0;
	int j=i-1;
	printf("R");
	while(i<len)
		{
		printf("%c",cell[i]);
		i++;
		}
	printf("C");
	while(j>=0)
		{
		columns+=prod*((long long)(cell[j])-64);
		prod*=26;
		j--;
		}
	printf("%I64d\n",columns);
	}

void convert1(long long c, long long r)
	{
	node *start=NULL;
	node *temp;
	while(r>0)
		{
		temp=(node *)malloc(sizeof(node));
		if(r%26==0)
		{temp->ch='Z';
		r=r/26;
		r--;
		}
		else
		{temp->ch=(char)((r%26)+64);
		r=r/26;
		}
		temp->next=start;
		start=temp;

		}
		while(temp)
		{
		printf("%c",temp->ch);
		temp=temp->next;
		}
		printf("%I64d\n",c);
	}

int main()
	{
	char cell[16];
	int n;
	scanf("%d",&n);
	while(n--)
	{
	scanf("%s",cell);
	int len=strlen(cell);
	int count=0;
	int mode=0;
	long long c=0;
	long long r=0;
	int i=2;
	if(cell[0]=='R')
		{
		if(isdigit(cell[1]))
		{

		while(i<len)
			{
			if(cell[i]=='C')
			break;
			i++;
			}
			if(i<len)
			{
			mode=1;
			}
		}
		}
	if(mode==0)
		{
		convert0(cell,len);
		}
	if(mode==1)
		{
		int j=1;
		r=0;
		c=0;

		while(j<i)
			{
			r=r*10;
			r=r + (long long)cell[j]-48;
			j++;
			}
		j++;

		while(j<len)
			{
			c=c*10;
			c=c + (long long)cell[j]-48;
			j++;
			}
		convert1(r,c);
		}
		}
	}


#include<stdio.h>
#include<string.h>

typedef struct node
	{
	char ch;
	struct node *next;
	} node;

void convert0(char cell[],int len)
	{
	int i=0;
	while(!isdigit(cell[i]))
		{
		i++;
		}
	long long prod=1;
	long long columns=0;
	int j=i-1;
	printf("R");
	while(i<len)
		{
		printf("%c",cell[i]);
		i++;
		}
	printf("C");
	while(j>=0)
		{
		columns+=prod*((long long)(cell[j])-64);
		prod*=26;
		j--;
		}
	printf("%I64d\n",columns);
	}

void convert1(long long c, long long r)
	{
	node *start=NULL;
	node *temp;
	while(r>0)
		{
		temp=(node *)malloc(sizeof(node));
		if(r%26==0)
		{temp->ch='Z';
		r=r/26;
		r--;
		}
		else
		{temp->ch=(char)((r%26)+64);
		r=r/26;
		}
		temp->next=start;
		start=temp;

		}
		while(temp)
		{
		printf("%c",temp->ch);
		temp=temp->next;
		}
		printf("%I64d\n",c);
	}

int main()
	{
	char cell[16];
	int n;
	scanf("%d",&n);
	while(n--)
	{
	scanf("%s",cell);
	int len=strlen(cell);
	int count=0;
	int mode=0;
	long long c=0;
	long long r=0;
	int i=2;
	if(cell[0]=='R')
		{
		if(isdigit(cell[1]))
		{
		mode=1;
		while(i<len)
			{
			if(cell[i]=='C')
			break;
			i++;
			}
		}
		}
	if(mode==0)
		{
		convert0(cell,len);
		}
	if(mode==1)
		{
		int j=1;
		r=0;
		c=0;

		while(j<i)
			{
			r=r*10;
			r=r + (long long)cell[j]-48;
			j++;
			}
		j++;

		while(j<len)
			{
			c=c*10;
			c=c + (long long)cell[j]-48;
			j++;
			}
		convert1(r,c);
		}
		}
	}


#include<stdio.h>
#include<string.h>

typedef struct node
	{
	char ch;
	struct node *next;
	} node;

void convert0(char cell[],int len)
	{
	int i=0;
	while(!isdigit(cell[i]))
		{
		i++;
		}
	long long prod=1;
	long long columns=0;
	int j=i-1;
	printf("R");
	while(i<len)
		{
		printf("%c",cell[i]);
		i++;
		}
	printf("C");
	while(j>=0)
		{
		columns+=prod*((long long)(cell[j])-64);
		prod*=26;
		j--;
		}
	printf("%I64d\n",columns);
	}

void convert1(long long c, long long r)
	{
	node *start=NULL;
	node *temp;
	while(r>0)
		{
		temp=(node *)malloc(sizeof(node));
		temp->ch=(char)((r%26)+64);
		temp->next=start;
		start=temp;
		r=r/26;
		}
		while(temp)
		{
		printf("%c",temp->ch);
		temp=temp->next;
		}
		printf("%I64d\n",c);
	}

int main()
	{
	char cell[16];
	int n;
	scanf("%d",&n);
	while(n--)
	{
	scanf("%s",cell);
	int len=strlen(cell);
	int count=0;
	int mode=0;
	long long c=0;
	long long r=0;
	int i=2;
	if(cell[0]=='R')
		{
		while(i<len)
			{
			if(cell[i]=='C')
				{
				mode=1;
				break;
				}
			i++;
			}
		}
	if(mode==0)
		{
		convert0(cell,len);
		}
	if(mode==1)
		{
		int j=1;
		r=0;
		c=0;

		while(j<i)
			{
			r=r*10;
			r=r + (long long)cell[j]-48;
			j++;
			}
		j++;

		while(j<len)
			{
			c=c*10;
			c=c + (long long)cell[j]-48;
			j++;
			}
		convert1(r,c);
		}
		}
	}


#include<stdio.h>
#include<string.h>

typedef struct node
	{
	char ch;
	struct node *next;
	} node;

void convert0(char cell[],int len)
	{
	int i=0;
	while(!isdigit(cell[i]))
		{
		i++;
		}
	long long prod=1;
	long long columns=0;
	int j=i-1;
	printf("R");
	while(i<len)
		{
		printf("%c",cell[i]);
		i++;
		}
	printf("C");
	while(j>=0)
		{
		columns+=prod*((long long)(cell[j])-64);
		prod*=26;
		j--;
		}
	printf("%I64d\n",columns);
	}

void convert1(long long c, long long r)
	{
	node *start=NULL;
	node *temp;
	while(r>0)
		{
		temp=(node *)malloc(sizeof(node));
		if(r%26==0)
		{temp->ch='Z';
		r=r/26;
		r--;
		}
		else
		{temp->ch=(char)((r%26)+64);
		r=r/26;
		}
		temp->next=start;
		start=temp;

		}
		while(temp)
		{
		printf("%c",temp->ch);
		temp=temp->next;
		}
		printf("%I64d\n",c);
	}

int main()
	{
	char cell[16];
	int n;
	scanf("%d",&n);
	while(n--)
	{
	scanf("%s",cell);
	int len=strlen(cell);
	int count=0;
	int mode=0;
	long long c=0;
	long long r=0;
	int i=2;
	if(cell[0]=='R')
		{
		if(isdigit(cell[1]))
		{
		mode=1;
		while(i<len)
			{
			if(cell[i]=='C')
				{
				break;
				}
			i++;
			}
			}
		}
	if(mode==0)
		{
		convert0(cell,len);
		}
	if(mode==1)
		{
		int j=1;
		r=0;
		c=0;

		while(j<i)
			{
			r=r*10;
			r=r + (long long)cell[j]-48;
			j++;
			}
		j++;

		while(j<len)
			{
			c=c*10;
			c=c + (long long)cell[j]-48;
			j++;
			}
		convert1(r,c);
		}
		}
	}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
        char *number_chars = "0123456789";
        long long n;
        long long i, j;
        char *line = NULL;

        scanf("%ld", &n);

        for (i = 0; i < n; ++i) {
                char line[50];
                scanf("%s", line);

                int c_ind = strchr(line, 'C') - line;

                if (strchr(number_chars, line[1]) && 0 < c_ind && c_ind < 50) { //type RXCY
                        char row_sub[50];
                        strncpy(row_sub, line + 1, c_ind - 1);
                        row_sub[c_ind] = '\0';
                        long row = atol(row_sub);
                        long col = atol(line + c_ind + 1);
                        char col_sub[50];
                        for (j = 48; col > 0; --j) {
                                col_sub[j] = 'Z' - (26 - (col % 26));
                                col /= 26;
                        }
                        col_sub[49] = '\0';
                        printf("%s%ld\n", col_sub + j + 1, row);
                } else { //type alpha num
                        int row_ind;
                        for (j = 0; j < strlen(line); ++j)
                                if (line[j] >= '0' && line[j] <= '9') {
                                        row_ind = j;
                                        break;
                                }
                        long col;
                        for (j = 0; j < row_ind; ++j)
                                col += (long)pow(26, row_ind - j - 1) * (line[j] - 'A' + 1); long row = atol(line + row_ind);
                        printf("R%ldC%ld\n", row, col);
                }
        }
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
        char *number_chars = "0123456789";
        long n;
        long i, j, k;

        scanf("%ld\n", &n);

        for (i = 0; i < n; ++i) {
                char line[50];
                scanf("%s\n", line);

                if (strchr(number_chars, line[1]) && strchr(line, 'C') && strchr(line, 'C') - line > 1) { //type RXCY
                        int c_ind = strchr(line, 'C') - line;
                        char row_sub[50];
                        strncpy(row_sub, line + 1, c_ind - 1);
                        row_sub[c_ind - 1] = '\0';
                        long row = atol(row_sub);
                        long col = atol(line + c_ind + 1);
                        char col_sub[50];
                        for (j = 48; col > 0; --j) {
                                col_sub[j] = 'Z' - (26 - (col % 26));
                                col /= 26;
                        }
                        col_sub[49] = '\0';
                        printf("%s%ld\n", col_sub + j + 1, row);
                } else { //type alpha num
                        int row_ind;
                        for (j = 0; j < strlen(line); ++j)
                                if (line[j] >= '0' && line[j] <= '9') {
                                        row_ind = j;
                                        break;
                                }
                        long col = 0;
                        for (j = 0; j < row_ind; ++j) {
                                long power = 1;
                                for (k = 0; k < row_ind - j - 1; ++k)
                                        power *= 26;
                                col += power * (line[j] - 'A' + 1);
                        }
                        long row = atol(line + row_ind);
                        printf("R%ldC%ld\n", row, col);
                }
        }
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
        char *number_chars = "0123456789";
        long n;
        long i, j, k;
        char *line = NULL;

        scanf("%ld", &n);

        for (i = 0; i < n; ++i) {
                char line[50];
                scanf("%s", line);

                if (strchr(number_chars, line[1]) && strchr(line, 'C') && strchr(line, 'C') - line > 1) { //type RXCY
                        int c_ind = strchr(line, 'C') - line;
                        char row_sub[50];
                        strncpy(row_sub, line + 1, c_ind - 1);
                        row_sub[c_ind] = '\0';
                        long row = atol(row_sub);
                        long col = atol(line + c_ind + 1);
                        char col_sub[50];
                        for (j = 48; col > 0; --j) {
                                col_sub[j] = 'Z' - (26 - (col % 26));
                                col /= 26;
                        }
                        col_sub[49] = '\0';
                        printf("%s%ld\n", col_sub + j + 1, row);
                } else { //type alpha num
                        int row_ind;
                        for (j = 0; j < strlen(line); ++j)
                                if (line[j] >= '0' && line[j] <= '9') {
                                        row_ind = j;
                                        break;
                                }
                        long col = 0;
                        for (j = 0; j < row_ind; ++j) {
                                long power = 1;
                                for (k = 0; k < row_ind - j - 1; ++k)
                                        power *= 26;
                                col += power * (line[j] - 'A' + 1);
                        }
                        long row = atol(line + row_ind);
                        printf("R%ldC%ld\n", row, col);
                }
        }
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
        char *number_chars = "0123456789";
        long n;
        long i, j, k;

        scanf("%ld\n", &n);

        for (i = 0; i < n; ++i) {
                char line[50];
                scanf("%s\n", line);

                if (strchr(number_chars, line[1]) && strchr(line, 'C') && strchr(line, 'C') - line > 1) { //type RXCY
                        int c_ind = strchr(line, 'C') - line;
                        char row_sub[50];
                        strncpy(row_sub, line + 1, c_ind - 1);
                        row_sub[c_ind - 1] = '\0';
                        long row = atol(row_sub);
                        long col = atol(line + c_ind + 1);
                        char col_sub[50];
                        for (j = 48; col > 0; --j) {
                                col_sub[j] = 'A' + (col % 26 ? col % 26 - 1 : 25);
                                if (col_sub[j] == 'Z')
                                        --col;
                                col /= 26;
                        }
                        col_sub[49] = '\0';
                        printf("%s%ld\n", col_sub + j + 1, row);
                } else { //type alpha num
                        int row_ind;
                        for (j = 0; j < strlen(line); ++j)
                                if (line[j] >= '0' && line[j] <= '9') {
                                        row_ind = j;
                                        break;
                                }
                        long col = 0;
                        for (j = 0; j < row_ind; ++j) {
                                long power = 1;
                                for (k = 0; k < row_ind - j - 1; ++k)
                                        power *= 26;
                                col += power * (line[j] - 'A' + 1);
                        }
                        long row = atol(line + row_ind);
                        printf("R%ldC%ld\n", row, col);
                }
        }
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
        char *number_chars = "0123456789";
        long n;
        long i, j;
        char *line = NULL;

        scanf("%ld", &n);

        for (i = 0; i < n; ++i) {
                char line[50];
                scanf("%s", line);

                int c_ind = strchr(line, 'C') - line;

                if (strchr(number_chars, line[1]) && c_ind) { //type RXCY
                        char row_sub[50];
                        strncpy(row_sub, line + 1, c_ind - 1);
                        row_sub[c_ind] = '\0';
                        long row = atol(row_sub);
                        long col = atol(line + c_ind + 1);
                        char col_sub[50];
                        for (j = 48; col > 0; --j) {
                                col_sub[j] = 'Z' - (26 - (col % 26));
                                col /= 26;
                        }
                        col_sub[49] = '\0';
                        printf("%s%ld\n", col_sub + j + 1, row);
                } else { //type alpha num
                        int row_ind;
                        for (j = 0; j < strlen(line); j++)
                                if (line[j] >= '0' && line[j] <= '9')
                                        row_ind = j;
                        long col;
                        for (j = 0; j < row_ind; ++j)
                                col += (long)pow(26, row_ind - j - 2) * (line[j] - 'A' + 1);
                        long row = atol(line + row_ind - 1);
                        printf("R%ldC%ld\n", row, col);
                }
        }
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
        char *number_chars = "0123456789";
        long n;
        long i, j, k;
        char *line = NULL;

        scanf("%ld", &n);

        for (i = 0; i < n; ++i) {
                char line[50];
                scanf("%s", line);

                if (strchr(number_chars, line[1]) && strchr(line, 'C') && strchr(line, 'C') - line > 1) { //type RXCY
                        int c_ind = strchr(line, 'C') - line;
                        char row_sub[50];
                        strncpy(row_sub, line + 1, c_ind - 1);
                        row_sub[c_ind - 1] = '\0';
                        long row = atol(row_sub);
                        long col = atol(line + c_ind + 1);
                        char col_sub[50];
                        for (j = 48; col > 0; --j) {
                                col_sub[j] = 'Z' - (26 - (col % 26));
                                col /= 26;
                        }
                        col_sub[49] = '\0';
                        printf("%s%ld\n", col_sub + j + 1, row);
                } else { //type alpha num
                        int row_ind;
                        for (j = 0; j < strlen(line); ++j)
                                if (line[j] >= '0' && line[j] <= '9') {
                                        row_ind = j;
                                        break;
                                }
                        long col = 0;
                        for (j = 0; j < row_ind; ++j) {
                                long power = 1;
                                for (k = 0; k < row_ind - j - 1; ++k)
                                        power *= 26;
                                col += power * (line[j] - 'A' + 1);
                        }
                        long row = atol(line + row_ind);
                        printf("R%ldC%ld\n", row, col);
                }
        }
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
        char *number_chars = "0123456789";
        long long n;
        long long i, j;
        char *line = NULL;

        scanf("%ld", &n);

        for (i = 0; i < n; ++i) {
                char line[50];
                scanf("%s", line);

                int c_ind = strchr(line, 'C') - line;

                if (strchr(number_chars, line[1]) && 0 < c_ind && c_ind < 50) { //type RXCY
                        char row_sub[50];
                        strncpy(row_sub, line + 1, c_ind - 1);
                        row_sub[c_ind] = '\0';
                        long row = atol(row_sub);
                        long col = atol(line + c_ind + 1);
                        char col_sub[50];
                        for (j = 48; col > 0; --j) {
                                col_sub[j] = 'Z' - (26 - (col % 26));
                                col /= 26;
                        }
                        col_sub[49] = '\0';
                        printf("%s%ld\n", col_sub + j + 1, row);
                } else { //type alpha num
                        int row_ind;
                        for (j = 0; j < strlen(line); ++j)
                                if (line[j] >= '0' && line[j] <= '9') {
                                        row_ind = j;
                                        break;
                                }
                        long col = 0;
                        for (j = 0; j < row_ind - 1; ++j)
                                col += (long)pow(26, row_ind - j - 1) * (line[j] - 'A' + 1); long row = atol(line + row_ind);
                        printf("R%ldC%ld\n", row, col);
                }
        }
}


#include <stdio.h>
#include <ctype.h>

int main()
{
    char coord[17], colStrBuf[6], *colStr;
    int rows, cols, N, cnt;

    scanf("%d ", &N);
    while(N--)
    {
        gets(coord);
        cnt = sscanf(coord, "R%dC%d", &rows, &cols);

        if(cnt == 2)
        {
            colStrBuf[5] = '\0';
            for(colStr = colStrBuf+5; cols; cols/=26)
            {
                *(--colStr) = cols%26;
                if(! *colStr)
                {
                    cols -= 26;
                    *colStr += 26;
                }
                *colStr += 'A'-1;
            }

            printf("%s%d\n", colStr, rows);
        }
        else
        {
            cols = 0;
            for(colStr = coord; ! isdigit(*colStr); colStr++)
            {
                cols = cols*26 + (*colStr - 'A'+1);
            }

            sscanf(colStr, "%d", &rows);
            printf("R%dC%d\n", rows, cols);
        }
    }

    return 0;
}


#include <stdio.h>
#include <ctype.h>

int main()
{
    char coord[17], colStrBuf[6], *colStr;
    int rows, cols, N, cnt;

    scanf("%d ", &N);
    while(N--)
    {
        gets(coord);
        cnt = sscanf(coord, "R%dC%d", &rows, &cols);

        if(cnt == 2)
        {
            colStrBuf[5] = '\0';
            for(colStr = colStrBuf+5; cols; cols/=26)
            {
                *(--colStr) = cols%26 + 'A';
            }
            (*colStr)--;
            colStrBuf[4]--;
            printf("%s%d\n", colStr, rows);
        }
        else
        {
            cols = 0;
            (*coord)++;
            for(colStr = coord; ! isdigit(*colStr); colStr++)
            {
                cols = cols*26 + (*colStr - 'A');
            }
            cols++;

            sscanf(colStr, "%d", &rows);
            printf("R%dC%d\n", rows, cols);
        }
    }

    return 0;
}


#include <stdio.h>
#include <ctype.h>

int main()
{
    char coord[17], colStrBuf[6], *colStr;
    int rows, cols, N, cnt;

    scanf("%d ", &N);
    while(N--)
    {
        gets(coord);
        cnt = sscanf(coord, "R%dC%d", &rows, &cols);

        if(cnt == 2)
        {
            colStrBuf[5] = '\0';
            for(colStr = colStrBuf+5; cols; cols/=27)
            {
                *(--colStr) = cols%27 + 'A'-1;
            }
            printf("%s%d\n", colStr, rows);
        }
        else
        {
            cols = 0;
            for(colStr = coord; ! isdigit(*colStr); colStr++)
            {
                cols = cols*27 + (*colStr - 'A' + 1);
            }
            sscanf(colStr, "%d", &rows);
            printf("R%dC%d\n", rows, cols);
        }
    }

    return 0;
}


#include <stdio.h>
#include <ctype.h>

int main()
{
    char coord[17], colStrBuf[6], *colStr;
    int rows, cols, N;

    scanf("%d ", &N);
    while(N--)
    {
        gets(coord);

        if(coord[0] == 'R')
        {
            sscanf(coord, "R%dC%d", &rows, &cols);
            colStrBuf[5] = '\0';
            for(colStr = colStrBuf+5; cols; cols/=26)
            {
                *(--colStr) = cols%26 + 'A'-1;
            }
            printf("%s%d\n", colStr, rows);
        }
        else
        {
            cols = 0;
            for(colStr = coord; ! isdigit(*colStr); colStr++)
            {
                cols = cols*26 + (*colStr - 'A' + 1);
            }
            sscanf(colStr, "%d", &rows);
            printf("R%dC%d\n", rows, cols);
        }
    }

    return 0;
}


#include <stdio.h>
#include <ctype.h>

int main()
{
    char coord[50], colStrBuf[20], *colStr;
    int rows, cols, N;

    scanf("%d ", &N);
    while(N--)
    {
        gets(coord);

        if(coord[0] == 'R')
        {
            sscanf(coord, "R%dC%d", &rows, &cols);
            colStrBuf[19] = '\0';
            for(colStr = colStrBuf+19; cols; cols/=26)
            {
                *(--colStr) = cols%26 + 'A'-1;
            }
            printf("%s%d\n", colStr, rows);
        }
        else
        {
            cols = 0;
            for(colStr = coord; ! isdigit(*colStr); colStr++)
            {
                cols = cols*26 + (*colStr - 'A' + 1);
            }
            sscanf(colStr, "%d", &rows);
            printf("R%dC%d\n", rows, cols);
        }
    }

    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<cctype>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<set>
#include<vector>
#include<cstdio>
#include<stack>
#include<sstream>

using namespace std;
const int MAX=1000005;
typedef long long ll;
void tran(int x)
{
    if(x)
    {
       tran((x-1)/26);
       printf("%c",(x-1)%26+'A');
    }
}
int main()
{
    int n;
    scanf("%d",&n);
    while(n--)
    {
        char str[1000],*p;
        int a,b;
        scanf("%s",str);
        if(sscanf(str,"%*c%d%*c%d",&a,&b)==2)//这里用到了%*这个输入标准，还有sscanf.
        {
            tran(b);
            printf("%d\n",a);
        }
        else
        {
            for(a=0, p=str; *p>64; p++)  //64是ASCii那个表上的@，就是A前面的那个字符的编码
                a=a*26+*p-64;  //a*26是因为那个字母就是用的26进制，这样挨着计算，然后*p是取字符串的内容，每次向右移动了一位
            printf("R%sC%d\n",p,a);
        }
    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int a[1000005];
int b[1000005];
char s[20];
int ismath(char ch)
{
    if(ch>='0'&&ch<='9')return 1;
    else return 0;
}

int main()
{

int i, t, j, k, g, h, f, d, ans, n, m;

scanf("%d", &t);

while(t--)
{
memset(a, 0, sizeof(a));
memset(b, 0, sizeof(b));
int i;

scanf("%s", s);

k = j = g = f = d = 0;

for(i=0; s[i]; i++)//数字字母分开存， 用j即数字的个数判断是那种转换类型。
{
if(s[i]>='0'&&s[i]<='9')
{
b[j] = b[j] * 10 + s[i] -'0';
f = 1;
}

else if(s[i]>='A'&&s[i]<='Z')
{
a[k++] = s[i];

if(f==1)
j++;
}
}

if(j == 0)//把用字母表示的列数转换成数字。
{
ans = 0;

for(i = 0; a[i]; i++)
{
ans = ans * 26 + a[i] - 'A' + 1;//类似于把字符类型的数字转换成数字， 26一个周期。

}

printf("R%dC%d\n", b[0], ans);
}
else//把用数字表示的列数转换成字母。
{
K(b[1]);
printf("%d\n",b[0]);
}

}
return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<set>
#include<vector>
#include<cstdio>
#include<stack>
#include<sstream>
#include<cstring>
using namespace std;
const int MAX=1000005;
typedef long long ll;
void tran(int x)
{
    if(x)
    {
       tran((x-1)/26);
       printf("%c",(x-1)%26+'A');
    }
}
int main()
{
    int n;
    scanf("%d",&n);
    while(n--)
    {
        char str[1000],*p;
        int a,b;
        scanf("%s",str);
        if(sscanf(str,"%*c%d%*c%d",&a,&b)==2)//这里用到了%*这个输入标准，还有sscanf.
        {
            tran(b);
            printf("%d\n",a);
        }
        else
        {
            for(a=0, p=str; *p>64; p++)  //64是ASCii那个表上的@，就是A前面的那个字符的编码
                a=a*26+*p-64;  //a*26是因为那个字母就是用的26进制，这样挨着计算，然后*p是取字符串的内容，每次向右移动了一位
            printf("R%sC%d\n",p,a);
        }
    }
    return 0;
}


#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<cctype>
#include<stack>
#include<queue>
using namespace std;
const int MAX=1000005;
typedef long long ll;
void tran(int x)
{
    if(x)
    {
       tran((x-1)/26);
       printf("%c",(x-1)%26+'A');
    }
}
int main()
{
    int n;
    scanf("%d",&n);
    while(n--)
    {
        char str[1000],*p;
        int a,b;
        scanf("%s",str);
        if(sscanf(str,"%*c%d%*c%d",&a,&b)==2)//这里用到了%*这个输入标准，还有sscanf.
        {
            tran(b);
            printf("%d\n",a);
        }
        else
        {
            for(a=0, p=str; *p>64; p++)  //64是ASCii那个表上的@，就是A前面的那个字符的编码
                a=a*26+*p-64;  //a*26是因为那个字母就是用的26进制，这样挨着计算，然后*p是取字符串的内容，每次向右移动了一位
            printf("R%sC%d\n",p,a);
        }
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<cctype>
#include<stack>
#include<queue>
using namespace std;
const int MAX=1000005;
typedef long long ll;
void tran(int x)
{
    if(x)
    {
       tran((x-1)/26);
       printf("%c",(x-1)%26+'A');
    }
}
int main()
{
    int n;
    scanf("%d",&n);
    while(n--)
    {
        char str[1000],*p;
        int a,b;
        scanf("%s",str);
        if(sscanf(str,"%*c%d%*c%d",&a,&b)==2)//这里用到了%*这个输入标准，还有sscanf.
        {
            tran(b);
            printf("%d\n",a);
        }
        else
        {
            for(a=0, p=str; *p>64; p++)  //64是ASCii那个表上的@，就是A前面的那个字符的编码
                a=a*26+*p-64;  //a*26是因为那个字母就是用的26进制，这样挨着计算，然后*p是取字符串的内容，每次向右移动了一位
            printf("R%sC%d\n",p,a);
        }
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<math.h>

#define max(a, b)(a > b ? a : b)
#define N 110000
char s[N], a[N];
int b[N];

void K(int n)
{
if(n>26)
K((n-1)/26);

printf("%c",(n-1)%26+'A');
}

int main()
{

int i, t, j, k, g, h, f, d, ans, n, m;

scanf("%d", &t);

while(t--)
{
memset(a, 0, sizeof(a));
memset(b, 0, sizeof(b));

scanf("%s", s);

k = j = g = f = d = 0;

for(int i=0; s[i]; i++)//数字字母分开存， 用j即数字的个数判断是那种转换类型。
{
if(s[i]>='0'&&s[i]<='9')
{
b[j] = b[j] * 10 + s[i] -'0';
f = 1;
}

else if(s[i]>='A'&&s[i]<='Z')
{
a[k++] = s[i];

if(f==1)
j++;
}
}

if(j == 0)//把用字母表示的列数转换成数字。
{
ans = 0;

for(i = 0; a[i]; i++)
{
ans = ans * 26 + a[i] - 'A' + 1;//类似于把字符类型的数字转换成数字， 26一个周期。

}

printf("R%dC%d\n", b[0], ans);
}
else//把用数字表示的列数转换成字母。
{
K(b[1]);
printf("%d\n",b[0]);
}

}
return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<iomanip>
#include<set>
#include<vector>
#include<cstdio>
#include<stack>
#include<sstream>
#include<cstring>
using namespace std;
const int MAX=1000005;
typedef long long ll;
void tran(int x)
{
    if(x)
    {
       tran((x-1)/26);
       printf("%c",(x-1)%26+'A');
    }
}
int main()
{
    int n;
    cin>>n;
    while(n--)
    {
        char str[1000],*p;
        int a,b;
        cin>>str;
        if(sscanf(str,"%*c%d%*c%d",&a,&b)==2)//这里用到了%*这个输入标准，还有sscanf.
        {
            tran(b);
            printf("%d\n",a);
        }
        else
        {
            for(a=0, p=str; *p>64; p++)  //64是ASCii那个表上的@，就是A前面的那个字符的编码
                a=a*26+*p-64;  //a*26是因为那个字母就是用的26进制，这样挨着计算，然后*p是取字符串的内容，每次向右移动了一位
            printf("R%sC%d\n",p,a);
        }
    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char s[100005][16];
int ismath(char ch)
{
    if(ch>='0'&&ch<='9')return 1;
    else return 0;
}

int main()
{

int i, t, j, k, g, h, f, d, ans, n, m;

scanf("%d", &t);

while(t--)
{
memset(a, 0, sizeof(a));
memset(b, 0, sizeof(b));

scanf("%s", s);

k = j = g = f = d = 0;

for(int i=0; s[i]; i++)//数字字母分开存， 用j即数字的个数判断是那种转换类型。
{
if(s[i]>='0'&&s[i]<='9')
{
b[j] = b[j] * 10 + s[i] -'0';
f = 1;
}

else if(s[i]>='A'&&s[i]<='Z')
{
a[k++] = s[i];

if(f==1)
j++;
}
}

if(j == 0)//把用字母表示的列数转换成数字。
{
ans = 0;

for(i = 0; a[i]; i++)
{
ans = ans * 26 + a[i] - 'A' + 1;//类似于把字符类型的数字转换成数字， 26一个周期。

}

printf("R%dC%d\n", b[0], ans);
}
else//把用数字表示的列数转换成字母。
{
K(b[1]);
printf("%d\n",b[0]);
}

}
return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<iomanip>
#include<set>
#include<vector>
#include<cstdio>
#include<stack>
#include<sstream>
#include<cstring>
using namespace std;
const int MAX=1000005;
typedef long long ll;
void tran(int x)
{
    if(x)
    {
       tran((x-1)/26);
       printf("%c",(x-1)%26+'A');
    }
}
int main()
{
    int n;
    cin>>n;
    while(n--)
    {
        char str[1000],*p;
        int a,b;
        cin>>str;
        if(sscanf(str,"%*c%d%*c%d",&a,&b)==2)//这里用到了%*这个输入标准，还有sscanf.
        {
            tran(b);
            printf("%d\n",a);
        }
        else
        {
            for(a=0, p=str; *p>64; p++)  .//64是ASCii那个表上的@，就是A前面的那个字符的编码
                a=a*26+*p-64;  //a*26是因为那个字母就是用的26进制，这样挨着计算，然后*p是取字符串的内容，每次向右移动了一位
            printf("R%sC%d\n",p,a);
        }
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<iomanip>
#include<set>
#include<vector>
#include<cstdio>
#include<stack>
#include<sstream>
#include<cstring>
using namespace std;
const int MAX=1000005;
typedef long long ll;
void tran(int x)
{
    if(x)
    {
       tran((x-1)/26);
       printf("%c",(x-1)%26+'A');
    }
}
int main()
{
    int n;
    scanf("%d",&n);
    while(n--)
    {
        char str[1000],*p;
        int a,b;
        scanf("%s",str);
        if(sscanf(str,"%*c%d%*c%d",&a,&b)==2)//这里用到了%*这个输入标准，还有sscanf.
        {
            tran(b);
            printf("%d\n",a);
        }
        else
        {
            for(a=0, p=str; *p>64; p++)  //64是ASCii那个表上的@，就是A前面的那个字符的编码
                a=a*26+*p-64;  //a*26是因为那个字母就是用的26进制，这样挨着计算，然后*p是取字符串的内容，每次向右移动了一位
            printf("R%sC%d\n",p,a);
        }
    }
    return 0;
}


#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
using namespace std;
string t = "ZABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
    int n;
    cin >> n;
    while(n--)
    {
        char s[100];
        cin >> s;
        int x,y;
        if(sscanf(s,"%*c%d%*c%d",&x,&y)==2)      //判断初始形式
        {
             string ans =  "";                  //用于记录y转化的字母形式
             while(y / 26 >= 1)
             {
                 ans += t[y % 26];
                 if (y % 26 == 0)               //注意：如果能够整除，后一位需减一。
                 {
                    y /= 26;
                    y--;
                 }
                 else
                    y /= 26;
             }
             if (y != 0)
                 ans += t[y % 26];
             reverse(ans.begin(),ans.end());
             cout << ans;
             printf("%d\n",x);
        }
        else
        {
            int cnt = 0,sum = 0;
            double ans = 0;
            for( int i = 0; i < strlen(s); i++ )         //用cnt记录字母段的长度
            {
                if ( isalpha(s[i]) )
                {
                    cnt++;
                }
                else
                {
                    break;
                }
            }
            for (int  i = cnt - 1,j = 0; i >= 0; i--,j++)
            {
                if (j == 0)
                    sum += s[i] - 'A' + 1;
                else
                    sum += (s[i] - 'A' + 1) * (int)pow(26.0,j);     //相当于26进制
            }
            printf("R");
            for (int i = cnt; i < strlen(s); i++)
            {
                cout << s[i];
            }
            printf("C%d\n",sum);
        }
    }

    return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>

#define BUFF_SIZE 160
#define COL_BUFF_SIZE 50

int read_string(char *string, int size)
{
	int len = 0;
	char c;
	while((c = getc(stdin)) != '\n' && size > len) {
		string[len] = c;
		len++;
	}

	string[len] = '\0';
	return len;
}

void reverce(char *string, int len)
{
	char tmp;
	int i;
	for(i = 0; i < len/2; i++) {
		tmp = string[i];
		string[i] = string[len-i-1];
		string[len-i-1] = tmp;
	}
}

void convertAtoB(int row, int col)
{
	char c_col[COL_BUFF_SIZE];
	int mod, len = 0;
	while(col) {
		mod = col % 26;
		c_col[len] = 'A' + mod - 1;
		len++;

		if(col > 26) {
			col = (col - mod) / 26;
		} else {
			break;
		}
	}

	reverce(c_col, len);
	printf("%s%d\n", c_col, row);
}

void convertBtoA(int row, char *col)
{
	int i_col = 0;
	int i, len;
	for(i = 0, len = strlen(col); i < len; i++) {
		i_col += ((col[len-i-1] % 'A') + 1) * (pow(26, i));
	}

	printf("R%dC%d\n", row, i_col);
}

int main(void)
{
	int row, i_col, t;
	char buffer[BUFF_SIZE];
	char c_col[COL_BUFF_SIZE];

	scanf("%d\n", &t);
	while(t) {
		read_string(buffer, BUFF_SIZE);
		if(sscanf(buffer, "R%dC%d", &row, &i_col) == 2) {
			convertAtoB(row, i_col);
		} else if(sscanf(buffer, "%49[^0-9]%d", c_col, &row)) {
			convertBtoA(row, c_col);
		}

		t--;
	}

	// int c = 4;
	// while(c) {
	// 	c--;
	// }

	return 0;
}


#include <stdio.h>
#include <string.h>

#define BUFF_SIZE 160
#define COL_BUFF_SIZE 50

double pow(double base, double power)
{
	int i;
	double result = base;
	for(i = 1; i < power; i++) {
		result *= base;
	}

	return power == 0 ? 1 : result;
}

int read_string(char *string, int size)
{
	int len = 0;
	char c;
	while((c = getc(stdin)) != '\n' && size > len) {
		string[len] = c;
		len++;
	}

	string[len] = '\0';
	return len;
}

void reverce(char *string, int len)
{
	char tmp;
	int i;
	for(i = 0; i < len/2; i++) {
		tmp = string[i];
		string[i] = string[len-i-1];
		string[len-i-1] = tmp;
	}
}

void convertAtoB(int row, int col)
{
	char c_col[COL_BUFF_SIZE];
	int mod, len = 0;
	while(col) {
		mod = col % 26;
		mod = !mod ? 26 : mod;
		// printf("%d\n", mod);
		c_col[len] = 'A' + mod - 1;
		len++;

		if(col > 26) {
			col = (col - mod) / 26;
		} else {
			break;
		}
	}

	reverce(c_col, len);
	printf("%s%d\n", c_col, row);
}

void convertBtoA(int row, char *col)
{
	int i_col = 0;
	int i, len;
	for(i = 0, len = strlen(col); i < len; i++) {
		// printf("%d * %lf\n", (col[len-i-1] % 'A') + 1, pow(26, i));
		i_col += ((col[len-i-1] % 'A') + 1) * (pow(26, i));
	}

	printf("R%dC%d\n", row, i_col);
}

int main(void)
{
	int row, i_col, t;
	char buffer[BUFF_SIZE];
	char c_col[COL_BUFF_SIZE];

	scanf("%d\n", &t);
	while(t) {
		read_string(buffer, BUFF_SIZE);
		if(sscanf(buffer, "R%dC%d", &row, &i_col) == 2) {
			convertAtoB(row, i_col);
		} else if(sscanf(buffer, "%49[^0-9]%d", c_col, &row)) {
			convertBtoA(row, c_col);
		}

		t--;
	}

	return 0;
}


#include <stdio.h>
#include <string.h>

#define BUFF_SIZE 160
#define COL_BUFF_SIZE 50

double pow(double base, double power)
{
	int i;
	for(i = 1; i < power; i++) {
		base *= base;
	}

	return power == 0 ? 1 : base;
}

int read_string(char *string, int size)
{
	int len = 0;
	char c;
	while((c = getc(stdin)) != '\n' && size > len) {
		string[len] = c;
		len++;
	}

	string[len] = '\0';
	return len;
}

void reverce(char *string, int len)
{
	char tmp;
	int i;
	for(i = 0; i < len/2; i++) {
		tmp = string[i];
		string[i] = string[len-i-1];
		string[len-i-1] = tmp;
	}
}

void convertAtoB(int row, int col)
{
	char c_col[COL_BUFF_SIZE];
	int mod, len = 0;
	while(col) {
		mod = col % 26;
		mod = !mod ? 26 : mod;
		c_col[len] = 'A' + mR228C494od - 1;
		len++;

		if(col > 26) {
			col = (col - mod) / 26;
		} else {
			break;
		}
	}

	reverce(c_col, len);
	printf("%s%d\n", c_col, row);
}

void convertBtoA(int row, char *col)
{
	int i_col = 0;
	int i, len;
	for(i = 0, len = strlen(col); i < len; i++) {
		i_col += ((col[len-i-1] % 'A') + 1) * (pow(26, i));
	}

	printf("R%dC%d\n", row, i_col);
}

int main(void)
{
	int row, i_col, t;
	char buffer[BUFF_SIZE];
	char c_col[COL_BUFF_SIZE];

	scanf("%d\n", &t);
	while(t) {
		read_string(buffer, BUFF_SIZE);
		if(sscanf(buffer, "R%dC%d", &row, &i_col) == 2) {
			convertAtoB(row, i_col);
		} else if(sscanf(buffer, "%49[^0-9]%d", c_col, &row)) {
			convertBtoA(row, c_col);
		}

		t--;
	}

	// int c = 4;
	// while(c) {
	// 	c--;
	// }

	return 0;
}


#include <stdio.h>
#include <string.h>

#define BUFF_SIZE 160
#define COL_BUFF_SIZE 50

double pow(double base, double power)
{
	int i;
	double result = base;
	for(i = 1; i < power; i++) {
		result *= base;
	}

	return power == 0 ? 1 : result;
}

int read_string(char *string, int size)
{
	int len = 0;
	char c;
	while((c = getc(stdin)) != '\n' && size > len) {
		string[len] = c;
		len++;
	}

	string[len] = '\0';
	return len;
}

void reverce(char *string, int len)
{
	char tmp;
	int i;
	for(i = 0; i < len/2; i++) {
		tmp = string[i];
		string[i] = string[len-i-1];
		string[len-i-1] = tmp;
	}
}

void convertAtoB(int row, int col)
{
	char c_col[COL_BUFF_SIZE];
	int mod, len = 0;
	while(col) {
		mod = col % 26;
		mod = !mod ? 26 : mod;
		printf("%d\n", mod);
		c_col[len] = 'A' + mod - 1;
		len++;

		if(col > 26) {
			col = (col - mod) / 26;
		} else {
			break;
		}
	}

	reverce(c_col, len);
	printf("%s%d\n", c_col, row);
}

void convertBtoA(int row, char *col)
{
	int i_col = 0;
	int i, len;
	for(i = 0, len = strlen(col); i < len; i++) {
		// printf("%d * %lf\n", (col[len-i-1] % 'A') + 1, pow(26, i));
		i_col += ((col[len-i-1] % 'A') + 1) * (pow(26, i));
	}

	printf("R%dC%d\n", row, i_col);
}

int main(void)
{
	int row, i_col, t;
	char buffer[BUFF_SIZE];
	char c_col[COL_BUFF_SIZE];

	scanf("%d\n", &t);
	while(t) {
		read_string(buffer, BUFF_SIZE);
		if(sscanf(buffer, "R%dC%d", &row, &i_col) == 2) {
			convertAtoB(row, i_col);
		} else if(sscanf(buffer, "%49[^0-9]%d", c_col, &row)) {
			convertBtoA(row, c_col);
		}

		t--;
	}

	return 0;
}