

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
int main()
{
   ll n,q;
   cin>>n>>q;
   char a[n+1];
   ll sum[n+1];
   sum[0]=0;
   for(ll i=1;i<=n;i++)
   {
       cin>>a[i];
       if(i==1)
       {
           sum[i]=int(a[i])-96;
       }
       else
       {
           sum[i]=sum[i-1]+int(a[i])-96;
       }
   }
   ll l[q],r[q];
   for(ll i=0;i<q;i++)
   {
       cin>>l[i]>>r[i];
       ll ans=0;
         ans=sum[r[i]]-sum[l[i]-1];
       cout<<ans<<endl;
   }
   
   

    return 0;
}
