#include <bits/stdc++.h>

using namespace std;
int n,q,l,r;
string s;
int c;
long long z;
int g;
long long m;
int e;
int main(){
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin>>n>>q>>s;

        for(int i=1;i<=q;i++){
            cin>>l>>r;
            if((r-l+1)%2==0){ cout<<((r-l+1)/2)*((r-l+1)/2)<<'\n';}
            else cout<<((r-l+1)/2)*((r-l+1)/2+1)<<'\n';
        }
    

    return 0;
}