#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define rep(i, n) repr(i, 0, n) #define INF 2e9 #define MOD 1000000007 //#define MOD 998244353 #define LINF (long long)4e18 #define jck 3.141592 using ll = long long; using Pi = pair; using Pl = pair; int main(){ int N; cin >> N; vector A(N); rep(i,N) cin >> A[i]; vector sum1(N+1); vector sum2(N+1); repr(i,1,N){ if(A[i] >= A[i-1]) sum1[i+1] = sum1[i] + 1; if(A[i] <= A[i-1]) sum2[i+1] = sum2[i] + 1; } int Q; cin >> Q; while(Q--){ int l,r; cin >> l >> r; Pi ans; if(sum1[r+1]-sum1[l+1] == r-l) ans.first = 1; else ans.first = 0; if(sum2[r+1]-sum2[l+1] == r-l) ans.second = 1; else ans.second = 0; cout << ans.first << " " << ans.second << endl; } }