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