#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = a; i < b; i++)
#define cinn(a) for(auto &i:(a)) cin>>i;
#define mod 1000000007
#define bign 200000

using namespace std;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef long long ll;
typedef double dd;

int main(void){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
  int n, q;
  cin>>n>>q;
  string s;
  cin>>s;
  vector<vi> sum(26, vi(n + 1, 0));
  sum[s[0] - 'a'][1]++;
  for(int i = 2; i <= n; i++) {
    sum[s[i-1] - 'a'][i]++;
    for(int j = 0; j < 26; j++) {
      sum[j][i] += sum[j][i-1];
    }
  }
  for(int i = 0; i < q; i++) {
    ll l, r;
    cin>>l>>r;
    ll ans = 0;
    for(int j = 0; j < 26; j++) {
      ans += (sum[j][r] - sum[j][l-1]) * (j + 1);
    }
    cout<<ans<<endl;
  }
}

