#include <iostream> #include <string> using namespace std; bool islower(char ch) { if (ch >= 'a' && ch <= 'z') return true; return false; } bool isUpper(char ch) { if (ch >= 'A' && ch <= 'Z') return true; return false; } int main() { int T; char ch; int y, sum = 0; cin >> T; while (T--) { cin >> ch >> y; sum = y; if (islower(ch)) { sum = sum - ( ch - 'a'+ 1 ); } else { sum = sum + (ch - 'A' + 1); } cout << sum << endl; } return 0; }