#include <bits/stdc++.h>
using namespace std;
string s;
int n, q, a, b;
int main(){
    cin >> n >> q >> s;
    while(q--){
        cin >> a >> b;
       /* if((b-a+1)%2){
            int br7=(b-a+1)/2+1;
            cout << br7*(br7-1) <<  endl;
        }
        else{*/
        cout << (b-a+1)*(b-a+1)/4 << endl;
        //}
    }
    return 0;
}