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

#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define all(x) x.begin(), x.end()
#define fastread ios_base::sync_with_stdio(0);cin.tie(NULL)
#define sum(x) accumulate(all(x),0LL)
#define what_is(x) cerr << #x << " = " << (x) << '\n'
#define pb push_back

int main()
{
    fastread;
    int n,q;
    cin >> n >> q;
    vii v(n);
    for(int i=0;i<n;i++)
        cin >> v[i];
    while (q--) {
        int x,l,r;
        cin >> x >> l >> r;
        if (r == l) {
            if(v[l] == -1)
                cout << "0\n";
            else
                cout << "1\n";
        }
        else {
            cout << "1\n";
        }
    }
    return 0;
}