#include <bits/stdc++.h>
#include <sstream>
using namespace std;
#define ll long long int
#define fl(i, a, b) for (int i = a; i < b; i++)
#define ll long long int
#define ld long double
#define endl "\n"
#define vi vector<int>
#define vs vector<string>
#define pii pair<int, int>
#define vpii vector<pair<int, int>>

void solve()
{
}

int main()

{

	int n, q;
	cin >> n >> q;
	string s;
	int a[n];
	cin >> s;
	fl(i, 0, n)
	{
		if (i > 0)
		{
			a[i] = a[i - 1] + s[i] - 'a' + 1;
		}
		else
		{
			a[i] = s[i] - 'a' + 1;
		}
	}
	fl(i, 0, q)
	{
		int x, y;
		cin >> x >> y;
		if (x >= 2)
		{
			cout << a[y - 1] - a[x - 2] << endl;
		}
		else
		{
			cout << a[y - 1] << endl;
		}
	}

	return 0;
}