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