import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N = int(readline()) A = list(map(int,readline().split())) Q = int(readline()) m = map(int,read().split()) LR = zip(m,m) incr = [0] * N decr = [0] * N for i,(x,y) in enumerate(zip(A,A[1:]),1): incr[i] = incr[i-1] if x <= y else i decr[i] = decr[i-1] if x >= y else i answer = [] for L,R in LR: f = 1 if incr[R] <= L else 0 g = 1 if decr[R] <= L else 0 answer.append('{} {}'.format(f,g)) print('\n'.join(answer))