#include<bits/stdc++.h>
using namespace std;
int main () {
  int n, q;
  cin >> n >> q;
  string str;
  cin >> str;
  int s[n];
  s[0] = 0;
  for (int i = 0; i < n; i++) {
    s[i+1] = (str[i] & 31) + s[i];
  }
  while (q--) {
    int l, r;
    cin >> l >> r;
    int ans = s[r]-s[l-1];
    cout << ans << "\n";
  }
  return 0;
}