use proconio::input; use proconio::fastout; #[fastout] #[allow(non_snake_case)] fn main() { input! { T: usize, } assert!(1 <= T && T <= 200_000); for _ in 0..T { input! { (N, M): (usize, usize), } assert!(1 <= N && N <= 1_000_000_000); assert!(1 <= M && M <= 1_000_000_000); if M <= N { println!("{}", (N + 3) / 4); } else { println!("{}", (N + M + 7) / 8); } } }