#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e6 + 5;
const int INF = 1e18;
int l, r, k;
bool cmp(int a, int b){
if(a + b <= k){
return a < b;
}
return false;
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, q;
cin >> n >> q;
vector < int > a(n);
for(int &i : a)cin >> i;
while(q--){
cin >> l >> r >> k;
l--, r--;
vector < int > v;
for(int i = l; i <= r; i++)
v.push_back(a[i]);
int t = 0;
while(is_sorted(v.begin(), v.end()) == false && t < 100){
sort(v.begin(), v.end(), cmp);
t++;
}
if(is_sorted(v.begin(), v.end()) == true){
cout << 1 << endl;
}
else {
cout << 0 << endl;;
}
// cout << "Print Array: ";
// for(int i : v)
// cout << i << ' ';
// cout << endl;
}
}