1
2 1
-2 -3
 3
1 1
1
5 4
5 -1 4 2 0
1 2
69
 1
5 1
-5 -4 -3 -2 -1
 1
2 1
-6 -9
 1
1 398708496844866113
959414461
 1
2 1
-5 -4
 2
3 1
-1 -2 0
3 2
-1 -2 0
 1
5 1
-1 -2 -3 -4 -5
 1
2 1
-1000000000 -1000000000
 1
2 1
-199 -191
 1
1 1
-1000
 1
2 1
-5 -5
 1
5 5
-999999995 -999999996 -999999997 -999999998 -999999999
 1
3 1
-4 -5 -6
 1
1 1
-1
 1
3 1
-3 -4 -5
 1
3 1
-1000000000 -1000000000 -1000000000
 1
2 1
-10 -11
 1
3 3
-100 -100 -100
 1
3 1
-1 -2 -3
 1
5 5
-10 -9 -8 -7 -6
 1
4 1
-1 -1 -1 -1
 1
2 1
-1 -2
 1
3 999
1000000000 -1000000000 -31
 5
20 809014
289 -254 1 -109 -167 93 23 -37 -31 -109 204 59 296 49 132 0 -28 35 -197 -266
20 458494
113 218 -292 -298 179 258 -257 -20 296 76 -145 93 -282 -261 -159 -45 255 -107 171 63
14 876161
69 74 12 2 177 -113 103 93 38 -48 282 169 205 145
26 731742
76 190 -227 -81 -293 243 -122 -122 252 16 -88 243 -216 -275 -267 188 144 -245 -117 -244 -259 281 -273 -206 112 -51
20 327039
42 133 231 128 19 181 -137 193 136 75 -203 55 37 -155 -219 182 -178 -280 2 132
 4
6 4
219 57 -58 230 173 177
2 4
266 176
3 2
134 -190 202
5 69
-1000000000 -1000000000 1000000000 0 1000000000
 1
5 1
-9 -8 -7 -6 -5
 1
3 1
-1 -4 -10
 1
5 3
-4 -5 -6 -7 -8
 1
2 3
-3 -3
 1
5 1000000000000000000
-5 -4 -3 -2 -1

0 1  
 0  
6 0 5 3 1  
0  
 4 3 2 1 0  
 0 3  
 0  
 1 0  
 1 2 0  
1 0 2  
 0 1 2 3 4  
 0 0  
 8 0  
 0  
 0 0  
 0 1 2 3 4  
 0 1 2  
 0  
 0 1 2  
 0 0 0  
 0 1  
 0 0 0  
 0 1 2  
 4 3 2 1 0  
 0 0 0 0  
 0 1  
 0 2000000000 1000000031  
 555 12 267 157 99 359 289 229 235 157 470 325 562 315 398 266 238 301 69 0  
411 516 6 0 477 556 41 278 594 374 153 391 16 37 139 253 553 191 469 361  
213 208 270 280 105 395 179 189 244 330 0 113 77 137  
369 483 66 212 0 536 171 171 545 309 205 536 77 18 26 481 437 48 176 49 34 574 20 87 405 242  
189 98 0 103 212 50 368 38 95 156 434 176 194 386 450 49 409 511 229 99  
 277 115 0 288 231 235  
90 0  
324 0 392  
2000000000 2000000000 0 1000000000 0  
 4 3 2 1 0  
 0 3 9  
 0 1 2 3 4  
 0 0  
 0 1 2 3 4  

import math
"""def maxOccurences(numbers):
    i=1
    alice = 1
    bob = 0
    while i<len(numbers)-1:
        
        if numbers[i] == numbers[i-1] and alice == 1:
            numbers.pop(i-1)
            numbers.pop(i)
            bob = 1
            alice =0

        elif numbers[i] == numbers[i-1] and bob == 1:
            numbers.pop(i-1)
            number.pop(i)
            bob = 0
            alice=1
            
        i+=1
        
    if bob==0:
        print("Bob")
    else:
        print("Alice")
a = maxOccurences([1,3,3,1,5])
print(a)"""
"""n = int(input())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
myMap = dict()
for i in range(len(x)):
    if myMap.get(x[i])== None:
        myMap[x[i]]=1
for i in range(len(y)):
    if myMap.get(y[i]) == None:
        myMap[y[i]]=1
print(myMap)
if len(myMap)==n:
    print("I become the guy.")
else:
    print("Oh, my keyboard!")"""

"""testcases = int(input())
while testcases > 0:
    a,b,k = map(int,input().split())
    aFactor = math.ceil(k/2)
    bFactor = math.floor(k/2)
    pos = a*aFactor - b*bFactor
    print(pos)
    testcases-=1"""
"""n = int(input())
if n==1:
    print(-1)
else:
    i=1
    while i<=n:
        print(str(i+1)+ " " + str(i), end=" ")
        i+=2"""
"""testcases = int(input())
while testcases > 0:
    n = int(input())
    myArray = list(map(int,input().split()))
    myMap = dict()
    for i in range(len(myArray)):
        if myMap.get(myArray[i]) == None:
            myMap[myArray[i]]=1
        else:
            myMap[myArray[i]]+=1
    if len(myMap)==1:
        print(n)
    elif len(myMap)==n:
        print(1)
    else:
        a = max(myMap, key=myMap.get)
        print(myMap[a])
    testcases-=1"""

"""testcases = int(input())
while testcases > 0:
    myString = input()
    myMap = dict()
    for i in range(len(myString)):
        if myString[i]=="1":
            if myMap.get(myString[i])== None:
                myMap[myString[i]]=1
            else:
                myMap[myString[i]]+=1
    flag=0
    i=0
    zeroCount=0
    oneCount=0
    while i<len(myString):
        if myString[i]=="1":
            if flag!=1:
                flag=1
            while i<len(myString) and myString[i]=="1":
                oneCount+=1
                i+=1
        if flag==1:
            if oneCount == myMap["1"]:
                break
            else:
                zeroCount+=1
        i+=1
    print(zeroCount)
    testcases-=1"""

"""testcases = int(input())
while testcases > 0:
    n,m = map(int,input().split())
    myArray=[]
    for i in range(n):
        myString = input()
        myArray.append(myString)
    i=0
    j=m-1
    count=0
    while i<n-1:
        if myArray[i][j]=="R":
            count+=1
        i+=1
    i=n-1
    j=0
    while j<m-1:
        if myArray[i][j]=="D":
            count+=1
        j+=1
    print(count)
    testcases-=1"""

"""testcases = int(input())
while testcases > 0:
    x,y = map(int,input().split())
    myString = input()
    myMap=dict()
    flag1=0
    flag2=0
    for i in range(len(myString)):
        if myMap.get(myString[i])==None:
            myMap[myString[i]]=1
        else:
            myMap[myString[i]]+=1
    if x>0:
        if myMap.get('R')!=None:
            if myMap['R']>=x:
                flag1=1
    elif x<0:
        if myMap.get('L')!=None:
            if myMap['L']>=abs(x):
                flag1=1
    else:
        flag1=1
    if y>0:
        if myMap.get('U')!=None:
            if myMap['U']>=y:
                flag2=1
    elif y<0:
        if myMap.get('D')!=None:
            if myMap['D']>=abs(y):
                flag2=1
    else:
        flag2=1
    if flag1 and flag2:
        print("YES")
    else:
        print("NO")
    testcases-=1"""

"""length = int(input())
myString = input()

finalString = ""
i=0
j=1
while i<len(myString):
    finalString+=myString[i]
    i = i + j
    j = j + 1
print(finalString)"""

"""a = int(input())
b= a
while True:
    c = b
    c = str(c)
    total= 0
    for i in range(len(c)):
        total += int(c[i])
    if total%4==0:
        print(b)
        break
    else:
        b+=1"""
"""n=int(input())
myArray = list(map(int,input().split()))
myMap=dict()
for i in range(len(myArray)):
    if myMap.get(myArray[i])==None:
        myMap[myArray[i]]=1
    else:
        myMap[myArray[i]]+=1
a = max(myMap , key=myMap.get)
print(myMap[a])"""

"""testcases = int(input())
while testcases > 0:
    cost = 0
    n , c0 , c1 , h = map(int,input().split())
    myString = input()
    myMap= dict()
    for i in range(len(myString)):
        if myMap.get(myString[i])==None:
            myMap[myString[i]] = 1
        else:
            myMap[myString[i]] += 1
    if myMap.get('0')!=None and myMap.get('1') !=None:
        if c0*myMap['0'] < c1*myMap['1']:
            if h+c0 < c1:
                cost = c0*myMap['0'] + h*myMap['1'] + c0*myMap['1']
            else:
                cost = c0*myMap['0'] + c1*myMap['1']
        elif c0*myMap['0'] > c1*myMap['1']:
            if h+c1 < c0:
                cost = c1*myMap['1'] + h*myMap['0'] + c1*myMap['0']
            else:
                cost = c0*myMap['0'] + c1*myMap['1']
        else:
            cost = c0*myMap['0'] + c1*myMap['1']
    elif myMap.get('0') == None and myMap['1']!=None:
        if c0+h < c1:
            cost = c0*myMap['1'] + myMap['1']*h
        else:
            cost = c1*myMap['1']
    elif myMap.get('1')==None and myMap['0']!=None:
        if c1+h < c0:
            cost = h*myMap['0'] + c1*myMap['0']
        else:
            cost = c0*myMap['0']
    print(cost)
    testcases-=1"""

"""n,k = map(int,input().split())
myArray = list(map(int, input().split()))
maxNo = -1
count=0
for i in range(len(myArray)):
    maxNo = max(maxNo , myArray[i])
if maxNo <= k:
    print(len(myArray))
else:
    i=0
    j=len(myArray)-1
    while i<=j:
        if myArray[i] <= k:
            i+=1
            count+=1
        elif myArray[j] <= k:
            j-=1
            count+=1
        else:
            break
    print(count)"""

"""n = int(input())
myMap = dict()
myArray = list(map(int,input().split()))
for i in range(len(myArray)):
    if myMap.get(myArray[i])==None:
        myMap[myArray[i]]=1
    else:
        myMap[myArray[i]]+=1
i=0
while i<len(myArray):
    if myMap[myArray[i]] > 1:
        myMap[myArray[i]]-=1
        myArray.pop(i)
    else:
        i+=1
print(len(myArray))
for i in range(len(myArray)):
    print(myArray[i], end=" ")"""

"""sticks, k = map(int,input().split())
a = int(sticks/k)

if a%2==0:
    print("NO")
else:
    print("YES")"""

"""testcases = int(input())
while testcases > 0:
    n,m = map(int,input().split())
    myArray = list(map(int,input().split()))
    total = 0
    flag=0
    for i in range(1,len(myArray)):
        total+=myArray[i]
    if total > m-myArray[0]:
        print(m)
    else:
        print(total+myArray[0])
    testcases-=1"""

"""testcases = int(input())
while testcases>0:
    n = int(input())
    myString = input()
    length = 0
    i=len(myString)-1
    while i>=0:
        if myString[i]==")":
            length+=1
            i-=1
        else:
            break
    d = n-length
    if d>=length:
        print("NO")
    else:
        print("YES")
    testcases-=1"""

testcases = int(input())
while testcases > 0:
    n,k = map(int,input().split())
    myArray = list(map(int,input().split()))
    minElement = 1000000000
    maxElement = -1000000000
    minIndex = -1
    maxIndex = -1
    myList1=[]
    myList2=[]
    for i in range(len(myArray)):
        if myArray[i] < minElement:
            minElement = myArray[i]
            minIndex = i
        if myArray[i] > maxElement:
            maxElement = myArray[i]
            maxIndex = i
    for i in range(len(myArray)):
        myArray[i]=maxElement-myArray[i]
        myList1.append(myArray[i])
    for i in range(len(myArray)):
        myArray[i]=myArray[minIndex]-myArray[i]
        myList2.append(myArray[i])
    if k%2!=0:
        for i in range(len(myList1)):
            if i!=len(myList1)-1:
                print(myList1[i],end=" ")
            else:
                print(myList1[i])
    else:
        for i in range(len(myList2)):
            if i!=len(myList2)-1:
                print(myList2[i], end=" ")
            else:
                print(myList2[i])
    testcases-=1

   






    
