#include void solve() { long long int a, b, c, k; scanf("%lld %lld %lld %lld", &a, &b, &c, &k); long long int aa, bb, cc; for (; k > 0; k--) { aa = b + c; bb = c + a; cc = a + b; a = aa / 2; b = bb / 2; c = cc / 2; if (a == b && b == c) break; } printf("%lld\n", a + b + c); return; } int main() { int t; scanf("%d", &t); for (; t > 0; t--) solve(); return 0; }