#include <bits/stdc++.h>
using namespace std;
long long n,q,x[300005],y[300005],p,br,res;
string s;
int main(){
    cin>>n>>q>>s;
    br = 0;
    for(int i = 1; i <= q; i++){
       cin>>x[i]>>y[i];
    }
    for(int i = 0; i < n; i++){
        if(s[i] == '?') br++;
    }
    if(br == n){
        for(int i = 1; i <= q; i++){
            p = y[i]-x[i]+1;
            if(p % 2 == 1) cout<<(p/2+1)*(p/2)<< endl;
            else if(p % 2 == 0) cout<<(p/2)*(p/2)<< endl;
        }
    }

    //cout<<br<< endl;
    return 0;
}