#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n; cin >> n;
    int q; cin >> q;
    string s;
    cin >> s;
    while(q--){
        int l; cin >> l;
        int d; cin >> d;
        int duzina = d-l+1;
        int sestice = duzina/2;
        int sedmice = duzina-sestice;
        cout << sestice*sedmice << endl;
    }
    return 0;
}