#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define fast_in_out  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ln "\n"
#define sc scanf
#define pr printf
 
const double EPS = (double) 1e-9;
const double pii = acos(-1);
const int mod = 1000000007;
const int N = (int) 1e5;
ll a[27][N + 1];
 
void prefixSum2D()
{
    for(int i = 0; i < 27; i++)
    {
        for(int j = 1; j <= N; j++)
        {
            a[i][j] += a[i][j - 1];
        }
    }
//    for (int i = 0; i < 27; i++) {
//        for (int j = 0; j < 8; j++)
//            cout << a[i][j] << " ";
//        cout << "\n";
//    }
}
 
int main()
{
    fast_in_out;
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    map <char, int> mp;
    int num = 1;
    for(char i = 'a'; i <= 'z'; i++, num++)
    {
        mp[i] = num;
//        cout << i << " " << mp[i] << ln;
    }
    for(char i = 'a'; i <= 'z'; i++)
    {
        for(int j = 0; j < n; j++)
        {
            if(s[j] == i)
            {
//                cout << i << " " << s[j] << " " << j << " " << mp[i] << ln;
                a[mp[i]][j + 1]++;
            }
        }
    }
    prefixSum2D();
    for(int i = 0; i < q; i++)
    {
        int l, r;
        cin >> l >> r;
        ull sum = 0;
        for(ll j = 1; j < 27; j++)
        {
            ll x = a[j][r] - a[j][l - 1];
            x *= j;
            sum += x;
        }
        cout << sum << ln;
    }
}