#include <bits/stdc++.h>
using namespace std;
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#define putchar_unlocked _putchar_nolock
#endif
inline void read(int& x) {
x = 0;
char ch;
do{
ch = getchar_unlocked();
}
while (ch < '0' || ch > '9');
while (ch >= '0' && ch <= '9'){
x = (x << 3) + (x << 1) + ch - '0';
ch = getchar_unlocked();
}
}
const int MAXN = 1000005;
struct Query{
int l, r, k, i;
} q[MAXN];
bool operator< (Query &a, Query &b){
return a.r < b.r;
}
int n, m, w[MAXN], st[MAXN];
bitset<MAXN> ans;
#define lsb(x) ((x) & (-(x)))
struct Fenwick{ // 0-index suffix max
int t[MAXN];
Fenwick(){
memset(t, -1, sizeof(t));
}
void update(int X, int V){
X = n-X;
for(; X <= n; X += lsb(X)){
t[X] = max(t[X], V);
}
}
int query(int X){
X = n-X;
int ret = 0;
for(; X; X -= lsb(X)){
ret = max(ret, t[X]);
}
return ret;
}
} fw;
signed main(){
read(n);
read(m);
for(int i=0; i<n; i++){
read(w[i]);
}
for(int i=0; i<m; i++){
int l, r, k;
read(l);
read(r);
read(k);
l--; r--;
q[i] = {l, r, k, i};
}
sort(q, q+m);
auto qp = q;
auto stb = st;
for(int i=0; i<n; i++){
while(stb != st && w[*(stb-1)] <= w[i]){
stb--;
}
if(stb != st){
int tw = w[i] + w[*(stb-1)];
fw.update(*(stb-1), tw);
}
*(stb++) = i;
while(qp != q+m && qp->r == i){
ans[qp->i] = fw.query(qp->l) <= qp->k;
qp++;
}
}
for(int i=0; i<m; i++){
putchar_unlocked(ans[i] ? '1' : '0');
putchar_unlocked('\n');
}
return 0;
}