#include using namespace std; using lint = long long int; using pint = pair; using plint = pair; struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_; #define ALL(x) (x).begin(), (x).end() #define SZ(x) ((lint)(x).size()) #define POW2(n) (1LL << (n)) #define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i=i##_begin_;i--) #define REP(i, n) FOR(i,0,n) #define IREP(i, n) IFOR(i,0,n) template istream &operator>>(istream &is, vector &vec){ for (auto &v : vec) is >> v; return is; } int main() { int N; cin >> N; vector A(N), X(N), Y(N); cin >> A; IREP(i, N - 1) { if (A[i] <= A[i + 1]) X[i] = X[i + 1] + 1; if (A[i] >= A[i + 1]) Y[i] = Y[i + 1] + 1; } int Q; cin >> Q; REP(_, Q) { int L, R; cin >> L >> R; printf("%d %d\n", X[L] >= R - L, Y[L] >= R - L); } }