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