#include using namespace std; using ll = long long; ll calc(ll a, ll b, ll c, ll k) { if (k == 0) { return a + b + c; } if (a == b && b == c) { return a * 3; } return calc((b+c) >> 2, (c + a) >> 2, (a + b) >> 2, k - 1); } void solve() { ll a, b, c, k; scanf(" %lld %lld %lld %lld", &a, &b, &c, &k); printf("%lld\n", calc(a, b, c, k)); } int main () { int n; cin >> n; while (n--) { solve(); } }