local ffi = require("ffi") local C = ffi.C ffi.cdef[[ long long atoll(const char*); ]] local function lltonumber(str) return C.atoll(str) end local n = io.read("*n", "*l") for i = 1, n do local a, b, c, k = io.read():match("(%d+) (%d+) (%d+) (%d+)") a = lltonumber(a) b = lltonumber(b) c = lltonumber(c) k = lltonumber(k) while 0LL < k and (a ~= b or b ~= c) do k = k - 1LL a, b, c = (b + c) / 2LL, (c + a) / 2LL, (a + b) / 2LL end local ans = (a + b + c) ans = tostring(ans):gsub("LL", "") print(ans) end