N = int(input()) A = list(map(int,input().split())) dec = [1]*N c = 1 f = True for i in range(1,N) : if A[i-1] >= A[i] : if not f : f = True c += 1 dec[i-1] = c dec[i] = c else : dec[i] = c else : dec[i] = False f = False inc = [1]*N c = 1 f = True for i in range(1,N) : if A[i-1] <= A[i] : if not f : f = True c += 1 inc[i-1] = c inc[i] = c else : inc[i] = c else : inc[i] = False f = False for i in range(int(input())) : p,q = map(int,input().split()) if (inc[p] == False) or (inc[q] == False) : x = 0 elif inc[p] == inc[q] : x = 1 else : x = 0 if (dec[p] == False) or (dec[q] == False) : y = 0 #print(p,q,dec[p],dec[q]) elif dec[p] == dec[q] : y = 1 else : y = 0 print(x,y)