#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//#define int ll
using P = pair<int, int>;
#define all(x) x.begin(), x.end()
#define rep(x,s,e) for (auto x=(s)-((s)>(e));x!=(e)-((s)>(e));((s)<(e)?x++:x--))
#define sz(x) (int)x.size()
const char nl = '\n';
const int N = 1e5+10;
int st[N][17], p[N];
void build(vector<int> &a, int n) {
rep(i, 0, n)st[i][0] = a[i];
for (int j = 1; (1<<j) <= n; ++j) {
for (int i = 0; i+(1<<j) <= n; ++i)
st[i][j] = max(st[i][j-1], st[i+(1<<(j-1))][j-1]);
}
}
int f(int l, int r) {
int j = p[r-l+1];
return max(st[l][j], st[r-(1<<j)+1][j]);
}
void solve() {
int n, m; cin >> n >> m;
vector<int> a(n);
for (auto &i: a)cin >> i;
vector<int> g[1001];
rep(i, 0, n)g[a[i]].push_back(i);
rep(i, 2, N)p[i] = p[i/2]+1;
build(a, n);
while (m--) {
int l, r, k; cin >> l >> r >> k;
bool res = true; --l, --r;
rep(i, 1, 1001) {
int ub = upper_bound(all(g[i]), r) - g[i].begin();
--ub; int mx = 0;
if (ub >= 0 && g[i][ub] >= l)mx = f(l, g[i][ub]);
if (mx > i && mx+i>k){res = false;break;}
}
cout << res << nl;
}
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
solve();
return 0;
}