#include <iostream>
#include <vector>
#include <string>
#include <math.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, q; cin >> n >> q;
    vector<int> a(q), b(q);
    string s; cin >> s;
    for(int i = 0; i < q; i++)
    {
        cin >> a[i] >> b[i];
    }
    for(int i = 0; i < q; i++)
    {
        long long r = b[i] - a[i] + 1;
        if(b[i]!=a[i])
        {
        if(r%2 == 0)
        {
            r = r / 2;
            r = r * r;
        }
        else
        {
            r = r/2;
            r = r * (r+1);
        }
        }
        else
        {
            r = 0;
        }
        cout << r << endl;
    }
}