#pragma GCC optimize("Ofast") #include using namespace std; typedef long long int ll; typedef unsigned long long int ull; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll myRand(ll B) { return (ull) rng() % B; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int q; cin >> q; while (q--) { ll a,b,c,k; cin >> a >> b >> c >> k; auto slv = [&](auto slv,ll a,ll b,ll c,ll k)->ll{ ll sum = a+b+c; int cnt = a%2 + b%2 + c%2; if(cnt == 0 or cnt == 3 or k == 0) { return sum; } else { return slv(slv,(b+c)/2,(a+c)/2,(a+b)/2,k-1); } }; cout << slv(slv,a,b,c,k) << "\n"; } }