#include <bits/stdc++.h>
#define ubrzaj ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

long long n,q;
    vector<long long> v;

bool ok(deque<long long> dq,long long z){
for(auto x:dq)
    if((v[z]&v[x])<=(v[z]^v[x]))return false;
return true;
}

int main()
{
ubrzaj
    cin >> n >> q;v.resize(n);
    bool stepen2=true;
    for(long long i=0; i<n; i++){cin >> v[i];if(1<<(31-__builtin_clz(v[i]))!=v[i])stepen2=false;}
    if(stepen2){
    while(q--){
            long long l,r;cin >> l >> r;
            cout << r-l+1 << endl;
        }
    }
else{
    while(q--){
            long long l,r;cin >> l >> r;
            l--;r--;
            if(l==r){cout << "1" << endl; continue;}
            if(l==r-1){if((v[l]&v[r])>(v[l]^v[r]))cout << "2" << endl;
            else cout << "1" << endl;
             continue;}
            long long best=0;
            for(int i=l; i<=r; i++){
            long long b=i+1,a=i;
            deque<long long> dq;
            dq.push_back(i);
            while(!dq.empty() && b<=r){
                if(a==r)break;
                if(ok(dq,b)){
                dq.push_back(b);best=max(best,(long long)dq.size());}
                b++;
                if(b==r+1){
                dq.pop_front();a=dq.front();b=a+1;}
            }
            }
            cout << best << endl;
        }
}
    return 0;
}