#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> prev(n  + 1);
    for (int i = 0; i < n; i++) {
        prev[i + 1] = prev[i] + (s[i] - 'a') + 1;
    }
    for (int i = 0; i < q; i++) {
        int l, r;
        cin >> l >> r;
        cout << prev[r] - prev[l - 1] << '\n';
    }
    return 0;
}
