#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;
  string s;
  cin >> n >> T >> s;
  vvi pre(26, vi(n+1, 0));
  for (int i=1; i<=n; ++i) {
    int j = s[i-1] - 'a';
    for (int c=0; c<26; ++c) {
      pre[c][i] = pre[c][i-1];
      if (c == j) pre[c][i]++;
    }
  }
  for (int test=0; test<T; ++test) {
    int l, r;
    cin >> l >> r, l--;
    vi cnts(26);
    int len = 0;
    for (int i=0; i<26; ++i) {
      int cnt = pre[i][r] - pre[i][l];
      if (cnt) {
        len += cnt*(i+1);
      }
    }
    cout << len << "\n";
  }

  return 0;
}