use std::io::Read; fn run() { let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); let mut it = s.trim().split_whitespace(); let n: usize = it.next().unwrap().parse().unwrap(); let a: Vec = (0..n).map(|_| it.next().unwrap().parse().unwrap()).collect(); let mut b = vec![0; n]; let mut c = vec![0; n]; for i in 1..n { if a[i - 1] < a[i] { b[i - 1] = 1; } if a[i - 1] > a[i] { c[i - 1] = 1; } } for i in (1..n).rev() { b[i - 1] += b[i]; c[i - 1] += c[i]; } let q: usize = it.next().unwrap().parse().unwrap(); let mut ans = String::new(); for _ in 0..q { let l: usize = it.next().unwrap().parse().unwrap(); let r: usize = it.next().unwrap().parse().unwrap(); let x = if c[l] - c[r] > 0 {0} else {1}; let y = if b[l] - b[r] > 0 {0} else {1}; ans.push_str(&format!("{} {}\n", x, y)); } print!("{}", ans); } fn main() { run(); }