#include<bits/stdc++.h>
using namespace std;

int main(){
	int n, q;
	
	cin >> n >> q;
	
	string s;
	cin >> s;
	vector<int> res(q);

	int l, r;
	for(int i = 0; i < q; ++i){
		cin >> l >> r;
		res[i] = (r-l+1)*(r-l+1)/4;
	}
	for(int i = 0; i < q; ++i){
		cout << res[i] << endl;
	}
	
}