#include <bits/stdc++.h>
using namespace std;

// Debugging
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;

// Shorthand for commonly used types
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;


int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;

  // SOLUTION
  int n, T;
  cin >> n >> T;
  string s;
  cin >> s;
  vvi pre(26, vi(n+1));
  for (int i=1; i<=n; ++i) {
    int c = s[i-1]-'a';
    for (int j=0; j<26; ++j) {
      pre[j][i] = pre[j][i-1] + (j == c ? 1 : 0);
    }
  }

  for (int test=0; test<T; ++test) {
    int l, r, ans = 0;
    cin >> l >> r;
    vi cnts(26);
    set<int> order;
    for (int j=0; j<26; ++j) {
      int cnt = cnts[j] = pre[j][r] - pre[j][l-1];
      if (cnt == 0) continue;
      order.insert(j);
    }
    
    // int rank = 1;
    for (int j : order) ans += (j+1)*cnts[j];

    cout << ans << "\n";
  }

  return 0;
}