#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FAST ios::sync_with_stdio(false); cin.tie(0),cout.tie(0);
//(a/b)%m =((a%m)*pow(b,m-2)%m)%m

void solve(){
    int n, q;
    cin>>n>>q;
    string s;
    cin>>s;
    vector<vector<int> > v(26, vector<int> (n+1, 0));
    for(int i=0; i<26; i++){
        for(int j=1; j<=n; j++){
            if(s[j-1] == 'a' + i){
                v[i][j] = v[i][j-1] + 1;
            }
            else{
                v[i][j] = v[i][j-1];
            }
        }
    }
    while(q--){
        int l, r;
        cin>>l>>r;
        int ans = 0;
        for(int i=0; i<26; i++){
            ans += (v[i][r] - v[i][l-1])*(i+1);
        }
        cout<<ans<<"\n";
    }
    return;
}

int main(){
    int T = 1;
    //cin>>T;
    while(T--){
        solve();
    }
    return 0;
}