#include using namespace std; typedef long long ll; // #define DEBUG int main() { #ifdef DEBUG cout << "DEBUG MODE" << endl; ifstream in("input.txt"); //for debug cin.rdbuf(in.rdbuf()); //for debug #endif int n, q, s1, s2, l, r; cin >> n; ll a[n]; bool lt[n-1], gt[n-1]; int lt_acum[n], gt_acum[n]; s1 = s2 = lt_acum[0] = gt_acum[0] = 0; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n-1; i++){ lt[i] = a[i+1] <= a[i]; s1 += lt[i]; lt_acum[i+1] = s1; gt[i] = a[i+1] >= a[i]; s2 += gt[i]; gt_acum[i+1] = s2; } // for (int i = 0; i < n; i++) // { // cout << gt_acum[i] << " "; // } // cout << endl; // for (int i = 0; i < n; i++) // { // cout << lt_acum[i] << " "; // } // cout << endl; cin >> q; for (int i = 0; i < q; i++){ cin >> l >> r; cout << ( (gt_acum[r] - gt_acum[l] == r - l) ? 1 : 0 ) << " "; cout << ( (lt_acum[r] - lt_acum[l] == r - l) ? 1 : 0 ) << endl; } return 0; }