#include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; int main(){ int N; cin >> N; vector v; rep(i,N){ ll a; cin >> a; v.push_back(a); } vector age(N-1,0),sage(N-1,0); rep(i,N-1){ if(v[i] <= v[i+1]) age[i] = 1; if(v[i] >= v[i+1]) sage[i] = 1; } vector sum_age(N,0), sum_sage(N,0); REP(i,1,N){ sum_age[i] = sum_age[i-1] + age[i-1]; sum_sage[i] = sum_sage[i-1] + sage[i-1]; } int Q; cin >> Q; rep(i,Q){ int l, r; cin >> l >> r; int fl = 0, fr = 0; if(sum_age[r] - sum_age[l] == r-l) fl = 1; if(sum_sage[r] - sum_sage[l] == r-l) fr = 1; cout << fl << " " << fr << endl; } return 0; }