use std::io::Read; fn main() { let mut s = String::new(); std::io::stdin().read_to_string(&mut s).ok(); s.lines().skip(1).for_each(|l| { let v: Vec = l.split(' ').flat_map(str::parse).collect(); let m = v[0].min(v[2]); let (a, b, c, d) = (v[0] - m, v[1] / 2, v[2] - m, v[1] % 2); println!("{}", 2 * (m + b) + a.min(d) + c / 2); }); }