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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, Q;
    cin >> N >> Q;
    string s;
    cin >> s;
    for(int i = 0;i < Q;i++){
        int L , R;
        cin >> L >> R;
        int x = (R-L+1)/2;
        cout << x*(x + (R-L+1)%2) << '\n';
    }
    return 0;
}