#include <bits/stdc++.h>

using namespace std;

int main()
{
    int q,n,x,y,uk;
    cin >> n >> q;
    string a;
    cin >> a;
    for(int Q=0;Q<q;Q++){
        cin >> x >> y;
        uk=y-x+1;
        if(uk%2==0){
            cout << ((uk/2)*(uk/2)) << endl;
        }
        else{
            cout << ((uk/2+1)*(uk/2)) << endl;
        }
    }
    return 0;
}