### u_n=2^(n-1)*(a+b)-b
def po(a,n,mod):
res=a
ans=1
while(n):
if(n%2):
ans=ans*res%mod
res=res*res%mod
n=n//2
return ans
def solve(a,b,n):
mod = 1000000007
b = b%mod
a = a%mod
mu = (n-1)%(mod-1)
po2 = po(2,mu,mod)
summ = (a+b)%mod
anss = po2*summ%mod
anss = (anss -b +mod) %mod
print(anss)
testcase = int(input())
while(testcase>0):
aa = list(map(int,input().split()))
a = aa[0]
b = aa[1]
n = aa[2]
solve(a,b,n)
testcase=testcase-1
IyMjIHVfbj0yXihuLTEpKihhK2IpLWIKZGVmIHBvKGEsbixtb2QpOgogICAgcmVzPWEKICAgIGFucz0xCiAgICB3aGlsZShuKToKICAgICAgICBpZihuJTIpOgogICAgICAgICAgICBhbnM9YW5zKnJlcyVtb2QKICAgICAgICByZXM9cmVzKnJlcyVtb2QKICAgICAgICBuPW4vLzIKICAgIHJldHVybiBhbnMKZGVmIHNvbHZlKGEsYixuKToKICAgIG1vZCA9IDEwMDAwMDAwMDcKICAgIGIgPSBiJW1vZAogICAgYSA9IGElbW9kCiAgICBtdSA9IChuLTEpJShtb2QtMSkKICAgIHBvMiA9IHBvKDIsbXUsbW9kKQogICAgc3VtbSA9IChhK2IpJW1vZAogICAgYW5zcyA9IHBvMipzdW1tJW1vZAogICAgYW5zcyA9IChhbnNzIC1iICttb2QpICVtb2QKICAgIHByaW50KGFuc3MpCnRlc3RjYXNlID0gaW50KGlucHV0KCkpCndoaWxlKHRlc3RjYXNlPjApOgogICAgYWEgPSBsaXN0KG1hcChpbnQsaW5wdXQoKS5zcGxpdCgpKSkKICAgIGEgPSBhYVswXQogICAgYiA9IGFhWzFdCiAgICBuID0gYWFbMl0KICAgIHNvbHZlKGEsYixuKQogICAgdGVzdGNhc2U9dGVzdGNhc2UtMQoK