#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int n,q,a,b,sum=0,songnum;
        cin>>n>>q;
        char song[n];
   cin>>song;
   int arr[n];
   arr[0]=(int)song[0]-96;
   for(int i=1;i<n;i++){
       songnum=(int)song[i];
       arr[i]=arr[i-1]+songnum-96;
      
         }
   
   while(q--){
          cin>>a>>b;
     cout<<arr[b-1]-arr[a-1]+song[a-1]-96<<endl;
   }
return 0;
}