#include <bits/stdc++.h>   #pragma GCC optimize( O2 )   using namespace std;   string conv(int n) {     string kq =   ;     while (n != 0) {       int r = n % 26;       if (r == 0) r = 26;       kq = char(r - 1 +  A ) + kq;       n = (n - r) / 26;     }     return kq;   }   int conv(string s) {     int kq = 0;     int n = s.size();     int tmp = 1;     for (int i = n - 1; i >= 0; i--) {       int k = int(s[i] -  A ) + 1;       kq += tmp * k;       tmp *= 26;     }     return kq;   }   int type(string s) {     if (s[0] !=  R ) return 1;     if (s[1] >=  A  && s[1] <=  Z ) return 1;     bool kt = false;     int n = s.size();     for (int i = 0; i <= n - 1; i++)       if (s[i] ==  C ) {         kt = true;         break;       }     if (!kt) return 1;     return 2;   }   void chuyen(string s) {     if (type(s) == 1) {       int n = s.size();       string x1 =   ;       int j = 0;       while (s[j] >=  A  && s[j] <=  Z ) {         x1 += s[j];         j++;       }       cout <<  R ;       for (int i = j; i <= n - 1; i++) cout << s[i];       cout <<  C  << conv(x1) <<   n ;     }     if (type(s) == 2) {       int kq = 0;       int tmp = 1;       int j = s.size() - 1;       while (s[j] >=  0  && s[j] <=  9 ) {         kq += (s[j] -  0 ) * tmp;         tmp *= 10;         j--;       }       cout << conv(kq);       for (int i = 1; i <= j - 1; i++) cout << s[i];       cout <<   n ;     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     while (n--) {       string s;       cin >> s;       chuyen(s);     }   }   