#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define f(i,m,n) for(int i = (m); i < (n); i++)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) sort(v.begin(),v.end())
#define sz(v) int(v.size())
const int MOD=1e9+7;
const int mod= 998244353;
typedef long long ll;
typedef vector<int> vi; 
typedef vector<pair<int,int>> vii; 
typedef vector<ll> vll; 
typedef pair<ll,ll> ii;
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
const double PI = acos(-1);

int main() {
	

    	int n,q;cin>>n>>q;
    	string s;
    	cin>>s;
    	ll arr[200000];
    	arr[0]=(s[0]-'a'+1)*1ll;
    	f(i,1,n){
    		arr[i]=arr[i-1]+(s[i]-'a'+1)*1ll;
    		
    		
    		
    	}
    	
    	f(i,0,q){
    		int l,r;cin>>l>>r;
    		l--;r--;
    		if(l>0){
    			cout<<arr[r]-arr[l-1]<<endl;
    		}
    		else cout<<arr[r]<<endl;
    		
    	}
        
    
    
   	
   	
  
	return 0;
}