T = int(input()) for _ in range(T): a,b,c,k = map(int,input().split()) for j in range(min(k, 200)): a,b,c = (a+b)//2, (b+c)//2, (c+a)//2 print(a+b+c)