#![allow(unused_macros, unused_imports, dead_code)] use std::any::TypeId; use std::cmp::{max, min, Reverse}; use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque}; use std::mem::swap; use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, Sub, SubAssign}; pub trait Identity { fn identity() -> Self; } impl Identity for i32 { fn identity() -> Self { 1_i32 } } impl Identity for u32 { fn identity() -> Self { 1_u32 } } impl Identity for i64 { fn identity() -> Self { 1_i64 } } impl Identity for u64 { fn identity() -> Self { 1_u64 } } impl Identity for i128 { fn identity() -> Self { 1_i128 } } impl Identity for u128 { fn identity() -> Self { 1_u128 } } impl Identity for f64 { fn identity() -> Self { 1_f64 } } impl Identity for usize { fn identity() -> Self { 1_usize } } mod matrix { use crate::Identity; use std::iter::Sum; use std::ops::{Index, IndexMut, Mul, MulAssign, Sub}; use std::slice::SliceIndex; #[derive(Clone)] pub struct Matrix { h: usize, w: usize, vals: Vec>, } impl + Mul + Sum<::Output>> Matrix { pub fn new(h: usize, w: usize) -> Self { let v1 = T::identity(); #[allow(clippy::eq_op)] let v0 = v1 - v1; Self { h, w, vals: vec![vec![v0; w]; h], } } pub fn identity(h: usize, w: usize) -> Self { debug_assert!(h == w); let v1 = T::identity(); #[allow(clippy::eq_op)] let v0 = v1 - v1; let mut vals = vec![vec![v0; w]; h]; for (y, line) in vals.iter_mut().enumerate() { for (x, val) in line.iter_mut().enumerate() { *val = if y == x { v1 } else { v0 }; } } Self { h, w, vals } } pub fn pow(&self, mut p: usize) -> Self { let mut ret = Self::identity(self.h, self.w); let mut mul = self.clone(); while p > 0 { if p & 1 != 0 { ret = ret.clone() * mul.clone(); } p >>= 1; mul = mul.clone() * mul.clone(); } ret } } impl]>> Index for Matrix { type Output = Idx::Output; fn index(&self, i: Idx) -> &Self::Output { &self.vals[i] } } impl]>> IndexMut for Matrix { fn index_mut(&mut self, index: Idx) -> &mut Self::Output { &mut self.vals[index] } } impl + Mul + Sum<::Output>> Mul> for Matrix { type Output = Matrix; fn mul(self, rhs: Matrix) -> Self::Output { debug_assert!(self.w == rhs.h); let mut ret = Self::new(self.h, rhs.w); for y in 0..ret.h { for x in 0..ret.w { ret[y][x] = (0..self.w).map(|i| self[y][i] * rhs[i][x]).sum::(); } } ret } } impl + Mul + Sum<::Output>> Mul> for Matrix { type Output = Vec; fn mul(self, rhs: Vec) -> Self::Output { debug_assert!(self.w == rhs.len()); let v1 = T::identity(); #[allow(clippy::eq_op)] let v0 = v1 - v1; let mut ret = vec![v0; self.h]; for y in 0..self.h { ret[y] = (0..self.w).map(|x| self[y][x] * rhs[x]).sum::(); } ret } } impl + Mul + Sum<::Output>> MulAssign> for Matrix { fn mul_assign(&mut self, rhs: Matrix) { *self = self.clone() * rhs; } } } use matrix::Matrix; mod procon_reader { use std::fmt::Debug; use std::io::Read; use std::str::FromStr; pub fn read() -> T where ::Err: Debug, { let stdin = std::io::stdin(); let mut stdin_lock = stdin.lock(); let mut u8b: [u8; 1] = [0]; loop { let mut buf: Vec = Vec::with_capacity(16); loop { let res = stdin_lock.read(&mut u8b); if res.unwrap_or(0) == 0 || u8b[0] <= b' ' { break; } else { buf.push(u8b[0]); } } if !buf.is_empty() { let ret = String::from_utf8(buf).unwrap(); return ret.parse().unwrap(); } } } pub fn read_vec(n: usize) -> Vec where ::Err: Debug, { (0..n).into_iter().map(|_| read::()).collect::>() } pub fn read_vec_sub1(n: usize) -> Vec { (0..n) .into_iter() .map(|_| read::() - 1) .collect::>() } pub fn read_mat(h: usize, w: usize) -> Vec> where ::Err: Debug, { (0..h) .into_iter() .map(|_| read_vec::(w)) .collect::>>() } } use procon_reader::*; /************************************************************************************* *************************************************************************************/ fn main() { let mut ans = vec![]; for _ in 0..read::() { let mut a = read::(); let mut b = read::(); let mut c = read::(); let k = read::(); for _ in 0..k { let na = (b + c) / 2; let nb = (c + a) / 2; let nc = (a + b) / 2; a = na; b = nb; c = nb; if a % 2 == 0 && b % 2 == 0 && c % 2 == 0{ break; } } ans.push(a + b + c); } eprintln!(); for ans in ans { println!("{}", ans); } }