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

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

    int n, q, a, b, c;
    cin >> n >> q;

    vector<int> v(n);

    for(int &i: v) {
        cin >> i;
    }

    while(q--) {
        cin >> a >> b >> c;

        if(b % 2 == 0 && c % 2 == 0) {
            cout << c - b << "\n";
        }
        else {
            cout << c - b + 1 << "\n";
        }
    }

}
