#include <iostream>
#include <vector>
#include <deque>

using namespace std;
int najduzi(const vector<int>& niz, int l, int d);
bool provera(int x, int y);


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, q;
    cin>>n>>q;

    vector<int> niz(n);
    for(int& i : niz)
        cin>>i;

    for(int i=0; i<q; i++)
    {
        int l, d;
        cin>>l>>d;
        l--; d--;
        cout<<najduzi(niz, l, d)<<"\n";
    }

    return 0;
}

bool provera(int x, int y)
{
    int res = x ^ y;
    int res2 = x & y;

    if(res < res2)
        return true;
    else
        return false;
}

int najduzi(const vector<int>& niz, int l, int d)
{
    deque<int> dek;
    int maks = 0;
    int k = 0;
    dek.push_back(niz[l]);
    for(int i=l+1; i<=d; i++)
    {
        if(provera(dek.back(), niz[i]))
            dek.push_back(niz[i]);
        else
        {
            while(!dek.empty())
            {
                k++;
                dek.pop_back();
            }
            if(k > maks)
                maks = k;
            k = 0;
            dek.push_back(niz[i]);
        }
    }
    if(!dek.empty())
    {
        k = dek.size();
        if(k > maks)
            maks = k;
    }

    return maks;
}