#include#include #include int fun(char c,int x){ int f[26]; int i; for(i=0;i<26;i++) f[i]=i+1; if(c>='A'&&c<='Z') return f[c-'A']+x; else return -f[c-'a']+x;}int main( ){ int N,y; char ch[10]; scanf("%d",&N); getchar(); while(N--) { scanf("%s%d",ch,&y); //printf("y:%d\n"); printf("%d\n",fun(ch[0],y));}return 0;}