class BIT: def __init__(self, N): self.size = N self.tree = [0] * (N + 1) def sum(self, i): s = 0 while i > 0: s += self.tree[i] i -= i & -i return s def add(self, i, x): while i <= self.size: self.tree[i] += x i += i & -i N, *I = map(int, open(0).read().split()) A = I[:N] Q, *LR = I[N:] up = BIT(N - 1) down = BIT(N - 1) for i in range(N - 1): d = A[i + 1] - A[i] if d >= 0: up.add(i + 1, 1) if d <= 0: down.add(i + 1, 1) for l, r in zip(*[iter(LR)] * 2): a = up.sum(r) - up.sum(l) b = down.sum(r) - down.sum(l) print( int(a == r - l), int(b == r - l) )