use proconio::input; use proconio::fastout; use std::cmp::max; #[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); println!("{}", max((N + 3) / 4, (N + M + 7) / 8)); } }