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