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

int n, q, raz;
string s;
int levi[300005], desni[300005];
bool prvi = true;
void set1(){

    for(int i = 1; i <= q; i++){
        raz = desni[i] - levi[i] + 1;
        //cout << raz << '\n';
        if((raz & 1) == 0){
            cout << (raz / 2) * (raz / 2) << '\n';
        }
        else{
            cout << (raz / 2 + 1) * (raz / 2) << '\n';
        }
    }
    return;
}
int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> n >> q;
    cin >> s;
    for(int i = 1; i <= q; i++){
        cin >> levi[i] >> desni[i];
    }
    for(int i = 0; i < n; i++){
        if(s[i] != '?'){
            prvi = false;
            break;
        }
    }
    if(prvi) set1();


    return 0;
}