#include <iostream>

using namespace std;


int main()
{
    int n,q, l,r;
    cin>>n>>q;
    string s;
    cin>>s;
    int arr[n];
    arr[0]=s[0]-'a'+1;
    for(int i=1;i<n;i++){
        arr[i]=arr[i-1]+s[i]-'a'+1;
    }
    while(q--){
        cin>>l>>r;
        cout<<(arr[r-1]-((l==1)?0:arr[l-2]))<<"\n";
    }
    return 0;
}
