#include <bits/stdc++.h>
#include <random>

using namespace std;

#define ll long long
#define endl '\n'
#define ld long double
#define pb push_back

const ll clasik = 7e5+7;
const ll INF = 1e17;
const ll mod = 1e9+7;
const ll mln = 1e6+111;

ll df[clasik];

void solve() {

    ll n , q;

    cin>>n>>q;

    for (int i = 1 ; i<=n ; i++) {
        cin>>df[i];
    }

    ll l , r;

    for (int i = 1 ; i<=n ; i++) {
        cin>>l>>r;
        if (l == r && l%2 == 0) {
            cout<<0<<endl;
            continue;
        }
        if (l%2==0) l++;
        if (r%2 == 0) r--;
        cout<<r-l+1<<endl;
    }

}

signed main() {
    
    int t = 1;

    //cin>>t;

    while(t--) solve();

    return 0;
}