#include<stdio.h> #include <iostream> #include<string.h> #include<stdlib.h> #include<math.h> #include<algorithm> #include<list> #include<vector> #pragma comment(linker,"/STACK:102400000,102400000") using namespace std; int main() { char f[27]={'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'}; char F[27]={'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 i ,n,x; char ch; scanf("%d",&n); while(n--) { getchar(); scanf("%c%d",&ch,&x); if('A'<=ch&&ch<='Z') { for(i=0;i<27;i++) if(ch==f[i]) printf("%d\n",i+x+1); } else { for(i=0;i<27;i++) if(ch==F[i]) printf("%d\n",x-i-1); } } return 0; }