#include <bits/stdc++.h>

using namespace std;

int nadji(int x){
    int c = 1;
    int d = 2;
    while(x<d){
        d *= 2;
        c++;
    }
    return c;
}

int solve(int l, int r, vector<int>& v){
    vector<int> pom(100, 0);
    int maks = -1;
    for(int i = l; i < r; i++){
        pom[v[i]]++;
        if(pom[v[i]]>maks){
            maks = pom[v[i]];
        }
    }
    return maks;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, q;
    cin >> n >> q;
    vector<int> v;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        v.push_back(nadji(x));
    }
    for(int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        cout << solve(l, r, v) << "\n";
    }
    return 0;
}