import sys,heapq input = sys.stdin.buffer.readline n=int(input()) A=[int(i) for i in input().split()] I,D=[0],[0] for i in range(1,n): if A[i]>=A[i-1]: I.append(I[-1]+1) else: I.append(I[-1]) if A[i]<=A[i-1]: D.append(D[-1]+1) else: D.append(D[-1]) q=int(input()) for _ in range(q): l,r=map(int,input().split()) ans1,ans2=0,0 if r-l==I[r]-I[l]: ans1=1 if r-l==D[r]-D[l]: ans2=1 print(ans1,ans2)