MOD = 10 ** 9 + 7 INF = 10 ** 10 import sys sys.setrecursionlimit(100000000) dy = (-1,0,1,0) dx = (0,1,0,-1) from collections import deque from heapq import heapify,heappush,heappop def main(): n = int(input()) a = list(map(int,input().split())) inc = [0] dec = [0] for i in range(n - 1): if a[i] == a[i + 1]: inc.append(1) dec.append(1) elif a[i] < a[i + 1]: inc.append(1) dec.append(0) else: inc.append(0) dec.append(1) for i in range(n - 1): inc[i + 1] += inc[i] dec[i + 1] += dec[i] q = int(input()) for _ in range(q): l,r = map(int,input().split()) if r == l: print(1,1) else: ans = [0,0] if inc[r] - inc[l] == r - l: ans[0] = 1 if dec[r] - dec[l] == r - l: ans[1] = 1 print(*ans) if __name__ == '__main__': main()