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

int main(){
    int n, q;
    cin>>n>>q;
    string s;
    cin>>s;
    bool prvi = true;
    for(char c: s) if(c!='?') {prvi = false; break;}
    if(prvi){
        while(q--){
            int l, r;
            cin>>l>>r;
            int d = r-l+1;
            if(d%2==0)
                cout<<d*d/4<<endl;
            else
                cout<<(d/2)*(d/2 + 1)<<endl;
        }
    }
}