#include<bits/stdc++.h>
#define int long long

using namespace std;
signed main()
{
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
int n,q;cin>>n>>q;
string s;cin>>s;int arr[n];
arr[0]=s[0]-96;
for(int i=1;i<n;i++){
arr[i]=arr[i-1]+(s[i]-96);
}
while(q--){
    int l,r;cin>>l>>r;l--;r--;int sum=arr[r]-arr[l]+(s[l]-96);
    
    cout<<sum<<"\n";
}
}
