#include<bits/stdc++.h>
using namespace std;
int n, q;
string s;
int l[300005], r[300005], niz[300005], res[300005];
bool t = true;
void set1(){
//    for(int i = 1; i <= q; i++){
//
//    }
    for(int i = 1; i <= q; i++){
        if(niz[i] == 1) res[i] = 0;
        else res[i] = (niz[i]/2)*(niz[i]-niz[i]/2);
    }
    for(int i = 1; i <= q; i++){
        cout << niz[i] << endl;
    }
    for(int i = 1; i <= q; i++){
        cout << res[i] << endl;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> q;
    cin >> s;
    for(int i = 0; i < n; i++){
        if(s[i] != '?') t = false;
    }
    for(int i = 1; i <= q; i++){
        cin >> l[i] >> r[i];
        niz[i]=r[i]-l[i]+1;
    }
    if(t) set1();
    return 0;
}