#include #include #include using namespace std; typedef long long ll; const int N_MAX = 100000; const ll A_MAX = 1000000000000000000; int main(){ int n; cin >> n; assert(1 <= n && n <= N_MAX); vector v(n); for(int i = 0; i < n; i++) cin >> v[i], assert(-A_MAX <= v[i] && v[i] <= A_MAX); vector gt(n, 0), lt(n, 0); for(int i = 1; i < n; i++){ gt[i] = gt[i-1] + (v[i-1] <= v[i]); lt[i] = lt[i-1] + (v[i-1] >= v[i]); } int q; cin >> q; assert(1 <= q && q <= N_MAX); while(q-- > 0){ int l, r; cin >> l >> r; assert(0 <= l && l <= r && r <= n-1); bool asc = (gt[r]-gt[l]) == r-l; bool dec = (lt[r]-lt[l]) == r-l; cout << asc << " " << dec << endl; } return 0; }