#include<iostream>
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n, q;
    vector<int> prefix;
    prefix.push_back(0);
    cin>>n>>q;
    string in;
    cin>>in;
    int sum=0;
    for(int i=0;i<n;i++){
        prefix.push_back(sum+in[i]-'a'+1);
        sum= sum+in[i]-'a'+1;
    }
    while(q--){
        int l,r;
        cin>>l>>r;
        cout<<prefix[r]-prefix[l-1]<<endl;
    }
}