macro_rules! get { ($t:ty) => { { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); line.trim().parse::<$t>().unwrap() } }; ($($t:ty),*) => { { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); let mut iter = line.split_whitespace(); ( $(iter.next().unwrap().parse::<$t>().unwrap(),)* ) } }; ($t:ty; $n:expr) => { (0..$n).map(|_| get!($t) ).collect::>() }; ($($t:ty),*; $n:expr) => { (0..$n).map(|_| get!($($t),*) ).collect::>() }; ($t:ty ;;) => { { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); line.split_whitespace() .map(|t| t.parse::<$t>().unwrap()) .collect::>() } }; ($t:ty ;; $n:expr) => { (0..$n).map(|_| get!($t ;;)).collect::>() }; } fn main() { let test_cases = get!(usize); for _ in 0..test_cases { let (mut a, mut b, mut c) = get!(i64, i64, i64); let mut result = 0; let b_count = b / 2; result += b_count * 2; b -= b_count * 2; let ac_count = a.min(c); a -= ac_count; c -= ac_count; result += ac_count * 2; let c_count = c / 2; result += c_count; c -= c_count * 2; let ab_count = a.min(b); result += ab_count; a -= ab_count; b -= ab_count; println!("{}", result); } }