#include using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } int main() { fast_io(); int t; cin >> t; for (; t--;) { long long a, b, c, k; cin >> a >> b >> c >> k; while (k > 0 && a != b) { long long na = (a + b) / 2; long long nb = (b + c) / 2; long long nc = (c + a) / 2; a = na; b = nb; c = nc; k--; } cout << a + b + c << '\n'; } }