
/* USACO ...
ID: rifats1
TASK: prob_name
LANG: C++                 
 
#include <iostream>
#include <fstream>
#include <string>
 
using namespace std;
 
int main() {
    ofstream fout ("prob_name.out");
    ifstream fin ("prob_name.in");
    
}
 
*/
 
#include  <bits/stdc++.h>

#define   ll             long long 
#define   pb             push_back
#define   mpa            make_pair
#define   nl             endl
#define   begin          begin()
#define   size           size()
#define   end            end()
#define   sp             " "
#define   Y              cout << "YES\n"
#define   N              cout << "NO\n"
#define   forn(i,n)      for(ll i=0;i<n;i++)
#define   form(j,m)      for(ll j=0;j<m;j++)
#define   rep(i,aa,bb)   for(ll i=aa;i<=bb;i++)
#define   repj(j,AA,BB)  for(ll j=AA;j<=BB;j++)
#define   pa(v)          for(ll i:v)cout<<i<<" ";cout<<endl;
#define   psa(v)         cout<<v.size<<endl;for(ll i:v)cout<<i<<" ";cout<<endl;
#define   pas            cout << v.size << endl;
 
 
 
 
using namespace std;
 

int main()
{
 
   ll n; cin >> n; ll m; cin >> m;

  
   string s; cin >> s;
  

   ll i=1;

   map <ll,ll> mp,lock;

   for(ll j=0;j<n;j++)
   {
   
        ll x = s[j]-'a';  if(lock[x]==0)
        {
             mp[x] = i;
             i++;
             lock[x]=1;
        }
     

       // cout << x << sp << mp[x] << endl;
   }
   map <ll,map <ll, ll> > ase;
   map <ll,ll> repi;

   forn(i,n)
   {
     ll x = s[i]-'a';
     repi[x]++;
     for(ll j=0;j<26;j++) ase[i][j] = repi[j];
   
   }
 


  

   while(m--)
   {
     ll l,r; cin >> l >>r;

     ll tot = 0;
     
     for(ll i=0;i<26;i++)
     {
       ll bam = ase[l-1][i];
       ll dan = ase[r-1][i];

       //cout   << bam << sp << dan << endl;
       ll rp = dan-bam;
       if((s[l-1]-'a')==i) rp++;

          ll val = (i+1)*rp;
          tot+=val;

         // cout << tot << endl;
       
     }

     cout  << tot << endl;
   }

  
   
}
 