#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int size, q;
    string s;
    cin >> size >> q >> s;
    
    vector<int> ps(size+1);
    ps[0] = 0;
    for(int i = 0; i < size; i++)
    {
        ps[i+1] = ps[i] + (int)s[i] - (int)'a' + 1;
    }
    
    for(int i = 0; i < q; i++)
    {
        int b, e;
        cin >> b >> e;
        b--;
        cout << ps[e] - ps[b] << endl;
    }
    
    
    return 0;
}