import java.io.InputStream; import java.io.PrintWriter; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Scanner; import java.util.Set; import java.util.TreeSet; import static java.util.Comparator.*; public class Main { public static void main(String[] args) { PrintWriter out = new PrintWriter(System.out); Solver solver = new Solver(System.in, out); solver.solve(); out.close(); } } class Solver { Scanner sc; PrintWriter out; public Solver(InputStream in, PrintWriter out) { sc = new Scanner(in); this.out = out; } // ================================================================== public void solve() { int N = Integer.parseInt(sc.next()); long a, sv; int[] up = new int[N]; int[] down = new int[N]; sv = Long.parseLong(sc.next()); for (int i = 1; i < N; i++) { a = Long.parseLong(sc.next()); if(sv < a) up[i] = 1; else if(sv > a) down[i] = 1; sv = a; } for (int i = 1; i < N; i++) { up[i] += up[i-1]; down[i] += down[i-1]; } int Q = Integer.parseInt(sc.next()); int l, r, uCnt, dCnt; for (int i = 0; i < Q; i++) { l = Integer.parseInt(sc.next()); r = Integer.parseInt(sc.next()); uCnt = up[r] - up[l]; dCnt = down[r] - down[l]; if(uCnt == 0 && dCnt == 0) out.println("1 1"); else if(uCnt > 0 && dCnt == 0) out.println("1 0"); else if(uCnt == 0 && dCnt > 0) out.println("0 1"); else out.println("0 0"); } } // ================================================================== } class PP{ public int key, val; public PP(int key, int val) { this.key = key; this.val = val; } public int getKey() { return key; } public int getVal() { return val; } }