import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] fArr = new int[n]; int[] gArr = new int[n]; long prev = sc.nextLong(); for (int i = 1; i < n; i++) { long x = sc.nextLong(); if (prev <= x) { fArr[i] = fArr[i - 1]; } else { fArr[i] = i; } if (prev >= x) { gArr[i] = gArr[i - 1]; } else { gArr[i] = i; } prev = x; } int q = sc.nextInt(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < q; i++) { int left = sc.nextInt(); int right = sc.nextInt(); if (fArr[right] <= left) { sb.append(1); } else { sb.append(0); } sb.append(" "); if (gArr[right] <= left) { sb.append(1); } else { sb.append(0); } sb.append("\n"); } System.out.print(sb); } }