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

int main()
{
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    while (q--)
    {
        int x, y, bs = 0, brp = 0;
        cin >> x >> y;
        /*for (int i = x - 1; i <= y - 1; i++)
        {
            if(s[i] == '?')
            {
                if (i < (y - x) / 2)
                {
                    s[i] = '6';
                }
                else
                {
                    s[i] = '7';
                }
            }
            if (s[i] == '6')
                bs++;
            else
                brp += bs;

        }
        cout << brp << '\n';*/
        int a = y - x + 1;
        if (a % 2 == 0)
            cout << (a / 2) * (a / 2);
        else
            cout << (a / 2) * ((a / 2) + 1);
    }
    return 0;
}