#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, q;
    cin >> n >> q;
    vector<long long> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    /*cout << "----\n";
    for (int i = 1; i < 20; ++i) {
        cout << i << ' ';
        for (int j = 1; j <= 100; ++j) {
            if ((i & j) > (i ^ j)) {
                cout << j << ' ';
            }
        }
        cout << '\n';
    }*/
    //cout << "\n------\n";
    /*for (int i = 1; i < 20; ++i) {
        cout << i << ' ';
        int k = floor(log2(i));
        int l = (1 << k);
        int r = (1 << (k + 1));
        for (int j = l; j < r; ++j) {
            cout << j << ' ';
        }
        cout << '\n';
    }*/
    while (q--) {
        int l, r;
        cin >> l >> r;
        --l, --r;
        vector<long long> k;
        for (int i = l; i <= r; ++i) {
            k.push_back(a[i]);
        }
        sort(k.begin(), k.end());
        int ans = 0;
        for (int i = 0; i < n; ++i) {
            long long x = floor(log2(k[i]));
            int L = (1ll << x), R = (1ll << (x + 1)) - 1;
            int id1 = lower_bound(k.begin(), k.end(), L) - k.begin();
            int id2 = upper_bound(k.begin(), k.end(), R) - k.begin();
            if (id2 > 0) {
                id2--;
            }
            ans = max(ans, id2 - id1 + 1);
        }
        cout << ans << '\n';
    }

    return 0;
}