#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;
struct segtree {
vector<vector<int>> tree;
vector<int> ans;
int size, mx, an;
void init(int n) {
size = 1;
while (size < n)size <<= 1;
tree.assign(2*size-1, {});
ans.assign(2*size-1, 0);
}
vector<int> merge(vector<int> x, vector<int> y) {
int l = 0, r = 0;
vector<int> res;
while (l < sz(x) && r < sz(y)) {
if (x[l] < y[r])res.push_back(x[l++]);
else res.push_back(y[r++]);
}
while (l < sz(x))res.push_back(x[l++]);
while (r < sz(y))res.push_back(y[r++]);
return res;
}
int calc(vector<int> x, vector<int> y) {
if (x.empty() || y.empty())return 0;
int l = x.back();
int lb = lower_bound(all(y), l) - y.begin();
--lb;
if (lb >= 0)return l+y[lb];
else return 0;
}
void build(vector<int> &a, int x, int lx, int rx) {
if (rx-lx==1) {
if (lx < sz(a))tree[x].push_back(a[lx]);
return;
}
int mid = lx+rx>>1;
build(a, 2*x+1, lx, mid);
build(a, 2*x+2, mid, rx);
tree[x] = merge(tree[2*x+1], tree[2*x+2]);
int m = calc(tree[2*x+1], tree[2*x+2]);
ans[x] = max(max(ans[2*x+1], ans[2*x+2]), m);
}
void build(vector<int> &a) {
init(sz(a));
build(a, 0, 0, size);
}
void get(int l, int r, int x, int lx, int rx, bool m = false) {
if (rx <= l || r <= lx)return;
if (l <= lx && rx <= r) {
if (tree[x].empty())return;
int lb = lower_bound(all(tree[x]), mx) - tree[x].begin();
--lb;
if (lb >= 0)
an = max(an, mx+tree[x][lb]);
an = max(an, ans[x]);
mx = max(mx, tree[x].back());
return;
}
int mid = lx+rx>>1;
get(l, r, 2*x+1, lx, mid);
get(l, r, 2*x+2, mid, rx);
}
void get(int l, int r) {
get(l, r, 0, 0, size);
}
};
void solve() {
int n, q; cin >> n >> q;
vector<int> a(n);
for (auto &i: a)cin >> i;
segtree st; st.build(a);
while (q--) {
int l, r, k; cin >> l >> r >> k;
--l;
st.mx = st.an = 0;
st.get(l, r);
if (st.an <= k)cout << '1' << nl;
else cout << '0' << nl;
}
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
solve();
return 0;
}