#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main()
{
   ll int n,q;
   string s;
   cin>>n>>q;
   ll int cum[n+2];
   cin>>s;
   cum[0]=s[0]-'a'+1;
   for(int i=1;i<n;i++)
   {

       cum[i]=cum[i-1]+s[i]-'a'+1;
   }

   for(ll int i=0;i<q;i++)
   {   ll int a,b,ans=0;
       cin>>a>>b;

       if (a==1)
       {cout<<cum[b-1]<<endl;}
       else
       {cout<<cum[b-1]-cum[a-2]<<endl;}

   }
}
