#include<bits/stdc++.h>
#include<map>
#include<stack>
#define ll long long int
#define Y cout << "YES" << endl;
#define N cout << "NO" << endl;
#define PRIYANK ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
vector<int> arr[1000001];
int vis[1000001];
int gvis[1001][1001];
void dfs(int node){
    vis[node] = 1;
    for(int i : arr[node]){
        if(vis[i] == 0){
            dfs(i);
        }
    }
}
bool isvalid(int x,int y, int n ,int m){
    if(x >= n || x < 0 || y >= m || y < 0 )
    return false;
    if(gvis[x][y]){
        return false;
    }
    return true;

}
int dx[] = { -1, 0 , 1 ,0};
int dy[] = {0 , 1 ,0,-1};

void gdfs(int x,int y){
    gvis[x][y] = 1;
    for(int i=0;i<4;i++){
        if(isvalid(x + dx[i],y + dy[i], 0,0)){
           gdfs(x + dx[i] , y + dy[i]);
        }
    }

}
void solve()
{
     ll n,q;
 cin>>n>>q;
 string s;
 cin>>s;
 vector <ll> m(n+1);
 m[0]=0;
 for(ll i=1;i<=n;i++)
 {
     m[i]=m[i-1]+s[i-1]-96;
 }
 for(int i=0;i<q;i++)
 {
     ll a,b;
     cin>>a>>b;
     cout<<m[b]-m[a-1]<<endl;
 }
 

}



int main()
{
    PRIYANK
    int t=1;
  // cin>>t;
    for(int i=0;i<t;i++)
    solve();
}