#pragma GCC optimize("Ofast") #include using namespace std; #define REP(i,n) for(int i = 0; i < (int)(n); ++i) #define ALL(a) (a).begin(),(a).end() typedef long long ll; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector A(N+1,0); REP(i,N){ cin >> A[i];} vector F(N+1,0), G(N+1,0); int f = 0; ll t = A[0]; REP(i,N-1){ if(A[i+1] >= t){ F[i+1] = f; }else{ t = A[i+1]; f++; F[i+1] = f; } } f = 0; t = A[0]; REP(i,N-1){ if(A[i+1] <= t){ t = A[i+1]; G[i+1] = f; }else{ t = A[i+1]; f++; G[i+1] = f; } } int q, l, r; cin >> q; REP(i,q){ cin >> l >> r; cout << (F[l]==F[r]) << " " << (G[l]==G[r]) << endl; } return 0; }