#include<iostream>
typedef long long ll;
using namespace std;

const int maxn =1e5+5;
int n,q;
ll sum[maxn];
string s;

int main() {
    cin>>n>>q;
    cin>>s;
    s = "#"+s;
    for(int i=1;i<=n;i++) sum[i] = sum[i-1]+s[i]-'a'+1;
    while (q--) {
        int l,r;
        cin>>l>>r;
        cout<<sum[r]-sum[l-1]<<endl;
    }
    return 0;
}