
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);




	long long int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	long long int arr[n + 1];
	long long int sum = 0;
	arr[0] = 0;
	for (int i = 1; i <= n; i++)
	{
		sum += s[i - 1] - 'a' + 1;
		arr[i] = sum;
	}
	while (q--)
	{
		long long int l, r;
		cin >> l >> r;
		cout << arr[r] - arr[l - 1] << endl;
	}






}
