#include<bits/stdc++.h>
using namespace std;
const int N=200010;
int a[N],b[N];
int main(){
    int n,q;
    cin>>n>>q;
    char s[N];
    cin>>s+1;
    for(int i=1;i<=n;i++){
        a[i]=s[i]-'a'+1;
        b[i]=b[i-1]+a[i];
    }
    while(q--){
        int l,r;
        cin>>l>>r;
        cout<<b[r]-b[l-1]<<endl;
    }
    
    
    return 0;
}