#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n, q;
vector<ll> a;
/*bool dobar(ll l, ll r){
    for (ll i=l;i<r;i++){
        for (ll j=i+1;j<=r;j++){
            if ((a[i]&a[j])<=(a[i]^a[j])) return false;
        }
    }
    return true;
}*/
ll setbit(ll a)
{
    ll m=1, ans=0;
    while (m<=a){
        if ((m&a)==m) ans++;
        m<<=1;
    }
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    //cout << setbit(2) << " " << setbit(7) << endl;
    cin >> n >> q;
    a.resize(n);
    bool stepen=true;
    map<ll, ll> m;
    for (ll i=0;i<n;i++){
        cin >> a[i];
        if (setbit(a[i])!=1) stepen=false;
        m[a[i]]++;
    }
    while (q--){
        ll l, r; cin >> l >> r;
        if (stepen) {cout << 1 << '\n'; continue;}
        /*l--; r--;
        if (l==r) {cout << 1 << '\n'; continue;}
        ll ans=1;
        for (ll i=l;i<r;i++){
            for (ll j=i+1;j<=r;j++){
                if (dobar(i, j)) ans=max(ans, (j-i+1));
            }
        }
        cout << ans << '\n';*/
    }
    return 0;
}