//author -> mystic_ankush
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define ff first
#define ss second
#define ii insert
#define mem(l,r) memset(l,r,sizeof(l))
#define sorta(a,n) sort(a+1,a+1+n)
#define sortv(v) sort(v.begin(),v.end())
#define revs(s) reverse(s.begin(),s.end())
#define fastio ios::sync_with_stdio(false), cin.tie(NULL);
const int N=1e5+5;
const int mod=1e9+7;
const ll int_max=1e18;
const ll int_min=-1e18;
#define rep(i,j,k) for(ll i=j;i<=k;i++)
#define repr(i,j,k) for(ll i=j;i>=k;i--)
const long double PI = acos(-1);
using namespace std;
ll freq[28]={0};
ll prefix[28][N];
void solve()
{
 	ll n,q;
 	cin>>n>>q;
 	string s;
 	cin>>s;
 
 	rep(i,0,n-1)
 	{
 		if(i==0){
 			rep(j,0,25)
 			{
 				int temp=s[i]-'a';
 				prefix[j][0]=(temp==j);
 			}
 			continue;
 			}
 		rep(j,0,25)
 		{
 			prefix[j][i]=prefix[j][i-1];
 			int temp=s[i]-'a';
 			prefix[j][i]+=(temp==j);
 		}
 	}
 	// rep(j,0,25)
 	// {
 		// rep(i,0,n-1)
 		// {
 			// cout<<prefix[j][i]<<' ';
 		// }
 		// cout<<'\n';
 	// }
 	while(q--)
 	{
 		ll l,r;
 		cin>>l>>r;
 		r--;
 		l--;
 		ll ans=0;
 		rep(j,0,25)
 		{
 			ll cnt=prefix[j][r]-prefix[j][l];
 			int temp=s[l]-'a';
 			if(temp==j)
 			cnt++;
 			ans+=cnt*(j+1);
 		}
 		cout<<ans<<'\n';
 	}
}
int main() {
    fastio
    solve();    
}