//* Problem  : 2102 - An Excel-lent Problem
//* Contest  : acm.tju.edu.cn
//* Type     : Solution
//* Date     : 2007.07.23
//* Author   : alt
//* Language : C++
//* Compiler : Microsoft Visual C++ 6.0

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

//#define ONLINE_JUDGE
char s[100];
int i, t;

int main()
{
	int r, c; char *str;
	gets(s); str = strchr(s, 'C'); *str = ' ';
	while (sscanf(&s[1], "%i %i", &r, &c) == 2 && r && c)
	{
		s[99] = 0;
		i = 98; c--; s[i] = c%26 + 'A'; c/=26;
		i--;
		
		while (c)
		{
			c--;
			s[i] = c%26 + 'A';
			c /= 26;
			i--;
		}
		i++;
		printf("%s%i\n", &s[i], r);
		gets(s); str = strchr(s, 'C'); *str = ' ';
	}
}