use std::io::*; fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let n: usize = itr.next().unwrap().parse().unwrap(); let a: Vec = (0..n) .map(|_| itr.next().unwrap().parse().unwrap()) .collect(); let q:usize = itr.next().unwrap().parse().unwrap(); let b: Vec<(usize, usize)> = (0..q).map(|_| {(itr.next().unwrap().parse().unwrap(),itr.next().unwrap().parse().unwrap(),)}).collect(); let mut inc: Vec = vec![0; n + 1]; let mut dec: Vec = vec![0; n + 1]; for i in 1..n { if a[i-1] <= a[i] { inc[i] += 1; } if a[i-1] >= a[i] { dec[i] += 1; } } for i in 0..n { inc[i+1] += inc[i]; dec[i+1] += dec[i]; } let mut out = Vec::new(); for i in 0..q { let l = b[i].0; let r = b[i].1; let mut f = 0; let mut g = 0; if r - l == inc[r] - inc[l] { f = 1; } if r - l == dec[r] - dec[l] { g = 1; } writeln!(out, "{} {}", f, g).ok(); } stdout().write_all(&out).unwrap(); }