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

int main() {
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<pair<int, int>> niska(q);

    int paran = 1;
    if (n % 2 == 0) paran = 0;

    for (int i = 0; i < q; i++) {
        cin >> niska[i].first;
        cin >> niska[i].second;
    }

    for (int i = 0; i < q; i++) {
        if (paran == 0) {
            int k = niska[i].second - niska[i].first + 1;
            k = k / 2;
            k = k * k;
            cout << k;
        }
        else {
            int nb = niska[i].second - niska[i].first + 1;
            int l = nb / 2;
            int k = l + 1;
            cout << l * k;
        }
    }
}