T=int(input()) for t in range(T): a,b,c,K=map(int,input().split()) for k in range(K): a,b,c=(b+c)//2,(c+a)//2,(a+b)//2 if a==b==c: print(a+b+c) break print(a+b+c)