#include <bits/stdc++.h>

using namespace std;

struct upit{

    int l;
    int d;
    int pos;

};

bool sort_func(const upit& a, const upit& b){
    return (a.l < b.l);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n,q;
    cin>>n>>q;

    vector<int> br(n+1);
    vector<int> st(34,0);

    vector<int> a(n+1);

    int cur_max = 0;

    for(int i=1;i<=n;i++){
        cin>>br[i];
        int stepen = floor(log2(br[i]));
        st[stepen]++;

        if(st[stepen] > cur_max){
            cur_max = st[stepen];
        }

        a[i] = cur_max;
    }

    vector<upit> upiti(q);

    int x,y;
    for(int i=0;i<q;i++){
        cin>>x>>y;
        upiti[i].l = x;
        upiti[i].d = y;
        upiti[i].pos = i;
    }

    sort(upiti.begin(),upiti.end(),sort_func);

    vector<int> ans(q);

    int pr_l = 1;
    for(int i=0;i<q;i++){

        if(upiti[i].l != pr_l){

            st = vector<int>(34,0);
            cur_max = 0;
            for(int j=upiti[i].l; j<=n;j++){

                int broj = br[j];

                int stepen = floor(log2(broj));
                st[stepen]++;
                if(st[stepen] > cur_max){
                    cur_max = st[stepen];
                }

                a[j] = cur_max;

            }

        }
        ans[upiti[i].pos] = a[upiti[i].d];
        pr_l = upiti[i].l;
    }


    for(int i=0;i<q;i++){
        cout<<ans[i]<<'\n';
    }

    return 0;
}