#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int N,Q,max,j;
    cin>>N>>Q;
    vector<char>T;
    for(int i=1;i<=N;i++)
    {
        char c;
        cin>>c;
        T.push_back(c);
    }
    while(Q--)
    {
        int X,Y;
        cin>>X>>Y;
        max=0;
        if((Y-X)%2!=0)cout<<(Y/2)*(Y/2)<<endl;
        else
        {
            for(int i=1,j=Y-1;X<Y;X++,i++,j--)
            {
                if(max<j*i)max=i*j;
            }
            cout<<max<<endl;
        }
    }
    system("pause");
    return 0;
}