from collections import * from itertools import * from functools import * import sys,math input = sys.stdin.readline def answer(): a,b,c,K = map(int,input().split()) bef = sorted([a,b,c]) for _ in range(K): a,b,c = (b+c)//2,(a+c)//2,(b+a)//2 aft = sorted([a,b,c]) if bef==aft: print(sum(aft)) return bef = aft[:] print(sum(aft)) return for _ in range(int(input())): answer()