import sys input = sys.stdin.readline for _ in range(int(input())): a, b, c, K = map(int, input().split()) for _ in range(K): a, b, c = (b+c)//2, (c+a)//2, (a+b)//2 if a==b==c: print(3*a) break else: print(a+b+c)