N = int(input()) A = list(map(int,input().split())) F = [0]*(N+1) G = [0]*(N+1) for i in range(1,N): a1 = A[i] a0 = A[i-1] if a1>=a0: F[i-1] = 1 if a1<=a0: G[i-1] = 1 cumF = [0]*N cumG = [0]*N cumF[0] = F[0] cumG[0] = G[0] for i in range(1,N-1): cumF[i] = cumF[i-1]+F[i] cumG[i] = cumG[i-1]+G[i] Q = int(input()) for _ in range(Q): l,r = map(int,input().split()) if l>0: up = cumF[r-1]-cumF[l-1] dow = cumG[r-1]-cumG[l-1] else: up = cumF[r-1] dow = cumG[r-1] flagF = 0 flagG = 0 if r-l==up: flagF = 1 if r-l==dow: flagG = 1 print(flagF,flagG)