#include<bits/stdc++.h>
#define ll long long int
using namespace std;
map<char,int>mp;
void solve()
{
    string s="abcdefghijklmnopqrstuvwxyz";
    for(ll i=0;i<s.length();i++)
    {
        mp[s[i]]=i+1;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll q,n;
    cin>>n>>q;
    solve();
    string s;
    cin>>s;
    ll a[n];
    for(ll i=0;i<n;i++)
    {
        a[i]=mp[s[i]];
    }
    for(ll i=1;i<n;i++)
    {
        a[i]+=a[i-1];
    }
    while(q--)
    {
        ll x,y;
        cin>>x>>y;
        if(x==1)
        cout<<a[y-1]<<"\n";
        else
        {
            //cout<<a[y-1]<<" "<<a[x-1]<<"\n";
            cout<<a[y-1]-a[x-2]<<"\n";
        }
    }
    return 0;
}