#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll findHighestSetBit_GCC(unsigned int n) {
    if (n == 0) {
        return -1; 
    }
    
    return 31 - __builtin_clz(n);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,q; cin >> n >> q;
    vector<ll> a(n);
    map<ll,vector<ll>>pronadji;
    for(int i = 0;i<n;i++){
        cin >>a[i];
        ll kljuc = findHighestSetBit_GCC(a[i]);
        pronadji[kljuc].push_back(i);
    }
    for(int i=0;i<q;i++){
        ll l,r; cin>> l >> r;
        ll maxi=0;
        while(l<r){
            ll broj=l-1;
            ll brojac=0;
            ll kljuc=findHighestSetBit_GCC(a[broj]);
            auto it = lower_bound(pronadji[kljuc].begin(), pronadji[kljuc].end(), r);
            brojac=it-pronadji[kljuc].begin();
            /*for(int j=0;j<pronadji[kljuc].size();j++){
                if(pronadji[kljuc][j]<r ){
                    brojac++;
                }
                else{
                    break;
                }
            }*/
            if(brojac>maxi){
                maxi=brojac;
            }
            l++;
        }
        cout<<maxi << '\n';
        
    
    }
    
    

    return 0;
}