#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n, q;
    cin >> n >> q;
    string niska; cin >> niska;

    string provera = "";
    for (int i = 0; i < n; i++) {
        provera += '?';
    }

    if (niska == provera) {
        while (q--) {
            int x, y;
            cin >> x >> y;

            int len = y - x + 1;

            cout << (len / 2) * (len - len / 2) << endl;
        }

    }

}