#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef vector<ll> vl;

ll n, q, k, j;

string s;

vl liste;

int main()
{
    cin >> n >> q;
    
    cin >> s;
    
    liste.push_back(0);
    
    for (int i = 0; i<n; i++){
        k=s[i]-'a'+1;
        liste.push_back(liste[i]+k);
    }
    
    for (int i= 0; i<q; i++){
        cin >> k >> j;
        cout << liste[j]-liste[k-1] << endl;
    }
    return 0;
}
