#include <bits/stdc++.h>
using namespace std;

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

    long long n, q, l, r;
    cin>>n>>q;
    long long a[n];
    for(long long i=0;i<n;i++){
        cin>>a[i];
    }
    while(q--){
        cin>>a[0]>>l>>r;
        if(l%2==0)l++;
        if(r%2==0)r--;
        cout<<max(0ll, r-l+1)<<'\n';
    }
}
