#define _USE_MATH_DEFINES #include using namespace std; //template #define rep(i,a,b) for(int i=(a);i<(b);i++) #define rrep(i,a,b) for(int i=(a);i>(b);i--) #define ALL(v) (v).begin(),(v).end() typedef long long int ll; typedef pair P; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } templatevoid Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);} const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2; //template end int main(){ int n,q; scanf("%d%d",&n,&q); int a[100010]; rep(i,0,n)scanf("%d",&a[i]); int tmp,l,r; vector> v(n+1); rep(i,0,q){ scanf("%d%d%d",&tmp,&l,&r); l--; r--; v[l].push_back({r,i}); } vector ans(q); vector

b; rrep(i,n-1,-1){ while(b.size()&&b.back().second