#include <bits/stdc++.h>
using namespace std;
#define ll long long
         int main(){
             int n,q;
             cin>>n>>q;
             string s;
             cin>>s;
             vector<int>a(n+1,0);
             for(int i=0;i<n;i++){
                 a[i+1]=a[i]+(s[i]-'a'+1);
                
             }
             while(q--){
             int l,r;
             cin>>l>>r;
             ll ans=a[r]-a[l-1];
             
 
             cout<<ans<<endl;
             }
         }
      
