#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define F first
#define S second

using namespace std;

int main()
{
    int n, q;
    string s;
    cin >> n >> q >> s;
    ll ans[n];
    ans[0] = s[0] - 'a' + 1;
    for(int i = 1; i < n; i++)
        ans[i] = ans[i - 1] + (s[i] - 'a') + 1;
    int l, r;
    while(q--){
        cin >> l >> r;
        l -= 2, r--;
        if(l == -1)
            cout << ans[r] << '\n';
        else
            cout << ans[r] - ans[l] << '\n';
    }
}
