#include <iostream>
#include <algorithm>
#include <vector>
#include <fstream>
#include <istream>
#include <iostream>
#include <string>


using namespace std;

int64_t countVector(vector<int> v, int th) {
	int64_t num = 0;
	for (int i = 0, j = v.size() - 1; i < j; i++) {
		while (j > i && v.at(i) + v.at(j) > th)j--;
		num += j - i;
	}
	return num;
}
int_fast32_t cnt[200001][27];
int main()
{

	int n, q, l, r;
	cin >> n >> q;
	string s;
	cin >> s;
	uint_fast32_t  counter = 0;
	for (uint_fast32_t i = 0; i < n; i++) {
		if (i > 0) {
			for (uint_fast8_t j = 0; j < 27; j++) {
				cnt[i][j] = cnt[i - 1][j];
			}
		}
		++cnt[i][s[i] - 97];
	}

	for (int i = 0; i < q; i++) {
		cin >> l >> r;
		r--;
		l--;
		for (uint_fast8_t j = 0; j < 27; j++) {
			if(l < 1) counter += (cnt[r][j]) * (j + 1);
			else counter += (cnt[r][j] - cnt[l-1][j]) * (j + 1);
		}
		cout << counter << endl;
		counter = 0;
	}

}
