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

#define fast ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define test()  int tt;  cin>>tt;  while(tt--)
#define nl  cout<<"\n"
#define sz(v) ((int)(v).size())

const int MOD = 1e9+7;
void solve()    {
      int n, q;   cin>>n>>q;
      string s;   cin>>s;
      vector<int> pos[26];
      for(int i=0; i<n; i++)  {
            pos[s[i]-'a'].pb(i);
      }
      while(q--)  {
            int l, r;   cin>>l>>r;
            l--;  r--;
            ll ans = 0;
            for(int j=0; j<26; j++) {
                  int cnt = upper_bound(all(pos[j]), r) - lower_bound(all(pos[j]), l);
                  ans += 1ll* cnt * (j+1);
            }
            cout<<ans<<"\n";
      }
}
int main()  {
      fast;
      #ifndef ONLINE_JUDGE
      freopen("inputf.in", "r", stdin);
      freopen("outputf.in", "w", stdout);
      #endif
      //test()
            solve();
}
