#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll,ll> 
#define mod 1000000007 
#define pb push_back
ll binpow(ll a,ll b){
    a %= mod;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}
int main(){
  ll t;
  t=1;
  while(t--){
    ll n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    vector<int> v(n+1,0);
    for(int i=1;i<=n;i++){
      v[i]=v[i-1]+s[i-1]-'a'+1;
    }
    while(q--){
      ll l,r;
      cin>>l>>r;
      cout<<v[r]-v[l-1]<<endl;
    }    
  }
  return 0;
}