#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(c) (c).begin(),(c).end()
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long double ld;
typedef pair<ll,ll> pii;
 
const ll inf = 1e9;
const ll inf64 = 1e18;
const ll MOD = inf + 7;

void solve()
{
    ll n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    ll a[n+1][26];
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<26;j++)
            a[i][j]=0;
    }   
    a[0][s[0]-97]=1;
    for(ll i=1;i<n;i++)
    {
        a[i][s[i]-97]=a[i][s[i]-97]+a[i-1][s[i]-97]+1;
        for(ll j=0;j<26;j++)
        {
            if(s[i]-97!=j)
                a[i][j]=a[i][j]+a[i-1][j];
        }
    }
    // for(ll i=0;i<n;i++)
    // {
    //     for(ll j=0;j<26;j++)
    //         cout<<a[i][j]<<" ";
    //     cout<<"\n";
    // }

    for(ll i=0;i<q;i++)
    {
        ll l,r;
        cin>>l>>r;
        l--,r--;
        ll ok=0;
        ll ans=0;
        for(ll j=0;j<26;j++)
        {
            ok=0;
            if(s[l]-97==j)
                ok=1;
            ll f=a[r][j]-a[l][j]+ok;
            //if(i==0)
            //cout<<j<<" "<<f<<"\n";
            ans=ans+f*(j+1);
        }
        cout<<ans<<"\n";
    }
}


int main() 
{
   fast;
   ll t=1;
   //cin>>t;
   while(t--)
    solve();

}