Being stuck at home, Ray became extremely bored. To pass time, he asks Lord Omkar to use his time bending power: Infinity Clock! However, Lord Omkar will only listen to mortals who can solve the following problem:

You are given an array $a$ of $n$ integers. You are also given an integer $k$. Lord Omkar wants you to do $k$ operations with this array.

Define one operation as the following:   Set $d$ to be the maximum value of your array.  For every $i$ from $1$ to $n$, replace $a_{i}$ with $d-a_{i}$. 

The goal is to predict the contents in the array after $k$ operations. Please help Ray determine what the final sequence will look like!


-----Input-----

Each test contains multiple test cases. The first line contains the number of cases $t$ ($1 \le t \le 100$). Description of the test cases follows.

The first line of each test case contains two integers $n$ and $k$ ($1 \leq n \leq 2 \cdot 10^5, 1 \leq k \leq 10^{18}$) – the length of your array and the number of operations to perform.

The second line of each test case contains $n$ integers $a_{1},a_{2},...,a_{n}$ $(-10^9 \leq a_{i} \leq 10^9)$ – the initial contents of your array.

It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$.


-----Output-----

For each case, print the final version of array $a$ after $k$ operations described above.


-----Example-----
Input
3
2 1
-199 192
5 19
5 -1 4 2 0
1 2
69

Output
391 0
0 6 1 3 5
0



-----Note-----

In the first test case the array changes as follows:

Initially, the array is $[-199, 192]$. $d = 192$.

After the operation, the array becomes $[d-(-199), d-192] = [391, 0]$.

Difficulty: MEDIUM

Starter code:

Solutions:
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if k % 2 != 0 or k == 1:
		k = 1
	else:
		k = 2
	d = max(a)
	M = 0
	while k:
		for i in range(n):
			a[i] = d - a[i]
			if a[i] >= M:
				M = a[i]
		d = M
		k -= 1
	for i in range(n):
		print(a[i], end=' ')
	print()


t = int(input())
for i in range(t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	list1 = list(map(int, input().split()))
	if k % 2 == 0:
		for j in range(2):
			d = max(list1)
			for i in range(n):
				list1[i] = d - list1[i]
	else:
		d = max(list1)
		for i in range(n):
			list1[i] = d - list1[i]
	print(*list1)


tests = int(input())
results = []
for _x in range(tests):
	x = [int(item) for item in input().split()]
	n = x[0]
	k = x[1]
	a = [int(item) for item in input().split()]
	mx = max(a)
	for i in range(2 if k % 2 == 0 else 1):
		for (i, item) in enumerate(a):
			a[i] = mx - item
		mx = max(a)
	results.append(a)
for res in results:
	print(*res, sep=' ')


T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	my_max = max(arr)
	arr1 = []
	arr2 = []
	for i in range(n):
		arr1.append(my_max - arr[i])
	max1 = max(arr1)
	for i in range(n):
		arr2.append(max1 - arr1[i])
	if k % 2 == 0:
		for i in range(n):
			print(arr2[i], end=' ')
	else:
		for i in range(n):
			print(arr1[i], end=' ')
	print()


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if k > 1:
		k = 2 + k % 2
	for i in range(k):
		b = max(a)
		for i in range(n):
			a[i] = b - a[i]
	print(*a)


for i in range(int(input())):
	(x, y) = map(int, input().split())
	z = list(map(int, input().split()))
	if y % 2 == 1:
		d = max(z)
		for k in range(len(z)):
			z[k] = d - z[k]
		print(*z, sep=' ')
	else:
		for j in range(2):
			d = max(z)
			for k in range(len(z)):
				z[k] = d - z[k]
		print(*z, sep=' ')


from collections import deque
from math import *
import heapq
from random import *
import sys
from copy import deepcopy
t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	m = max(l)
	for j in range(len(l)):
		l[j] = m - l[j]
	L = []
	M = max(l)
	for j in range(len(l)):
		L.append(M - l[j])
	if k % 2 == 1:
		print(*l)
	else:
		print(*L)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	k = k % 2
	a = list(map(int, input().split()))
	d = max(a)
	for i in range(n):
		a[i] = d - a[i]
	if k == 0:
		d = max(a)
		for i in range(n):
			a[i] = d - a[i]
	print(*a)


import sys, math
import io, os
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter

def data():
	return sys.stdin.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
from decimal import Decimal
from fractions import Fraction
INF = float('inf')
mod = int(1000000000.0) + 7
for t in range(int(data())):
	(n, k) = mdata()
	a = mdata()
	max1 = max(a)
	a1 = [0] * n
	a2 = [0] * n
	for i in range(n):
		a1[i] = max1 - a[i]
	max1 = max(a1)
	for i in range(n):
		a2[i] = max1 - a1[i]
	if k % 2:
		outl(a1)
	else:
		outl(a2)


for _ in range(int(input())):
	(n, k) = map(int, input().split(' '))
	A = list(map(int, str(input().strip()).split(' ')))
	if n == 1:
		print(0)
	else:
		z = k % 2
		if z == 1:
			_mx = max(A)
			print(*[_mx - x for x in A])
		else:
			_mx = max(A)
			A = [_mx - x for x in A]
			_mx = max(A)
			print(*[_mx - x for x in A])


def main():
	t = int(input())
	while t > 0:
		t -= 1
		soln()

def soln():
	nk = input()
	nk = nk.split(' ')
	n = int(nk[0])
	k = int(nk[1])
	a = list(map(int, input().split(' ')))
	d = max(a)
	if k == 0:
		par(a, n)
	else:
		d1 = 0
		for i in range(n):
			a[i] = d - a[i]
			d1 = max(d1, a[i])
		d = d1
		if k % 2 == 1:
			par(a, n)
		else:
			for i in range(n):
				a[i] = d - a[i]
			par(a, n)

def par(a, n):
	for i in range(n):
		if i == n - 1:
			print(a[i])
		else:
			print(a[i], end=' ')
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	if len(set(arr)) == 1:
		print('0 ' * n)
		continue
	d = max(arr)
	arr = [d - i for i in arr]
	if k % 2 != 1:
		d = max(arr)
		arr = [d - i for i in arr]
	print(*arr, sep=' ')


import sys
import math
from collections import Counter, defaultdict
input = sys.stdin.readline
LI = lambda : list(map(int, input().split()))
MAP = lambda : map(int, input().split())
IN = lambda : int(input())
S = lambda : input()

def case():
	(n, k) = MAP()
	a = LI()
	b = []
	c = []
	x = max(a)
	y = min(a)
	for i in range(n):
		b += [x - a[i]]
	x = max(b)
	for i in range(n):
		c += [x - b[i]]
	if k % 2:
		print(*b)
	else:
		print(*c)
for _ in range(IN()):
	case()


def solution(arr, k):
	m = max(arr)
	new = [m - i for i in arr]
	k = k - 1
	if k == 0:
		return new
	if k % 2 == 0:
		return new
	m = max(new)
	ans = [m - i for i in new]
	return ans
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = [int(x) for x in input().split()]
	print(*solution(arr, k))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = []
	d1 = max(a)
	for i in range(n):
		a[i] = d1 - a[i]
	d2 = max(a)
	for i in range(n):
		b.append(d2 - a[i])
	if k % 2 == 0:
		print(*b)
	else:
		print(*a)


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	k -= 1
	maxA = max(a)
	for i in range(n):
		a[i] = maxA - a[i]
	if k % 2 == 0:
		print(' '.join(map(str, a)))
	else:
		maxA = max(a)
		for i in range(n):
			a[i] = maxA - a[i]
		print(' '.join(map(str, a)))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	lis = list(map(int, input().split()))
	ma = max(lis)
	li1 = [ma - i for i in lis]
	ma = max(li1)
	li2 = [ma - i for i in li1]
	if k % 2:
		print(*li1)
	else:
		print(*li2)


import sys
pprint = lambda s: print(' '.join(map(lambda x: str(x), s)))
input = lambda : sys.stdin.readline().strip()
ipnut = input
for i in range(int(input())):
	(n, k) = map(int, input().split())
	a1 = list(map(int, input().split()))
	x = max(a1)
	a2 = list(map(lambda y: x - y, a1))
	x = max(a2)
	a3 = list(map(lambda y: x - y, a2))
	if k % 2:
		pprint(a2)
	else:
		pprint(a3)


for _ in range(int(input())):
	a = [int(x) for x in input().split()]
	(n, k) = (a[0], a[1])
	arr = [int(x) for x in input().split()]
	min_v = min(arr)
	max_v = max(arr)
	if k % 2 == 1:
		for i in range(n):
			arr[i] = max_v - arr[i]
	else:
		for i in range(n):
			arr[i] = arr[i] - min_v
	for e in arr:
		print(e, end=' ')
	print()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	mm = max(a)
	for i in range(0, n):
		a[i] = mm - a[i]
	if k % 2 == 1:
		print(*a)
	else:
		mm = max(a)
		for i in range(0, n):
			a[i] = mm - a[i]
		print(*a)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	l = [[]]
	for i in range(2):
		d = max(a)
		for j in range(n):
			a[j] = d - a[j]
		o = list(a)
		l.append(o)
	l.remove(l[0])
	if k % 2 == 0:
		print(*l[1])
	else:
		print(*l[0])


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ls = list(map(int, input().split()))
	k %= 2
	mx = max(ls)
	mn = min(ls)
	if k == 1:
		for i in range(n):
			ls[i] = mx - ls[i]
	else:
		for i in range(n):
			ls[i] = ls[i] - mn
	print(*ls)


import bisect
import functools
import itertools
import math
import heapq
import random

def repeat(_func=None, *, times=1):

	def decorator(func):

		@functools.wraps(func)
		def wrapper(*args, **kwargs):
			for _ in range(times):
				func(*args, **kwargs)
		return wrapper
	if _func is None:
		return decorator
	else:
		return decorator(_func)

def unpack(func=int):
	return map(func, input().split())

def l_unpack(func=int):
	return list(map(func, input().split()))

def s_unpack(func=int, rev=False):
	return sorted(map(func, input().split()), reverse=rev)

def ml_unpack(n):
	return [int(input()) for _ in range(n)]

def range_n():
	return range(int(input()))

def getint():
	return int(input())

def counter(a):
	d = {}
	for x in a:
		d[x] = d.get(x, 0) + 1
	return d

def factor(n):
	d = {}
	while not n % 2:
		d[2] = d.get(2, 0) + 1
		n //= 2
	i = 3
	while i * i <= n:
		while not n % i:
			d[i] = d.get(i, 0) + 1
			n //= i
		i += 2
	if n > 1:
		d[n] = d.get(n, 0) + 1
	return d

@repeat(times=getint())
def main():
	(n, k) = unpack()
	a = l_unpack()
	MAX = max(a)
	odd = [MAX - x for x in a]
	MAX = max(odd)
	even = [MAX - x for x in odd]
	if k & 1:
		ans = odd
	else:
		ans = even
	print(*ans)
main()


t = int(input())
for i in range(t):
	(a, b) = input().rstrip().split()
	x = int(a)
	y = int(b)
	arr = list(map(int, input().rstrip().split()))
	ma = arr[0]
	mi = arr[0]
	for j in range(x):
		if ma < arr[j]:
			ma = arr[j]
		elif mi > arr[j]:
			mi = arr[j]
	if y % 2 == 1:
		for j in range(x):
			arr[j] = ma - arr[j]
	else:
		for j in range(x):
			arr[j] = arr[j] - mi
	for j in range(x):
		print(arr[j], end=' ')
	print('')


for t in range(int(input())):
	tmp = input()
	n = int(tmp.split()[0])
	k = tmp.split()[1]
	k2 = int(k[-1]) % 2
	a = list(map(int, input().split(' ')))
	if not (len(k) == 1 and int(k) == 0):
		if k2 == 0:
			a1 = min(a)
			a = [x - a1 for x in a]
		elif k2 == 1:
			a2 = max(a)
			a = [a2 - x for x in a]
	print(*a)


try:
	for i1 in range(int(input())):
		(n, k) = map(int, input().split())
		a = list(map(int, input().split()))
		d = max(a)
		b = [0] * n
		for i in range(n):
			a[i] = d - a[i]
		x = max(a)
		for i in range(n):
			b[i] = x - a[i]
		for i in range(n):
			if k % 2 == 0:
				print(b[i], end=' ')
			else:
				print(a[i], end=' ')
		print()
except:
	pass


from sys import stdin
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	mx = max(a)
	for i in range(n):
		a[i] = mx - a[i]
	if k % 2 != 0:
		print(*a)
		continue
	mx = max(a)
	for i in range(n):
		a[i] = mx - a[i]
	print(*a)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	d = max(a)
	a1 = []
	a2 = []
	for i in a:
		a1.append(d - i)
	x = max(a1)
	for i in a1:
		a2.append(x - i)
	if k % 2 == 0:
		print(*a2)
	else:
		print(*a1)


import sys
input = sys.stdin.buffer.readline
inin = lambda : int(input())
inar = lambda : list(map(int, input().split()))
inst = lambda : input().decode().rstrip('\n\r')
INF = float('inf')
_T_ = inin()
for _t_ in range(_T_):
	(n, k) = inar()
	a = inar()
	d = max(a)
	o = [d - i for i in a]
	d = max(o)
	e = [d - i for i in o]
	if k % 2:
		print(*o)
	else:
		print(*e)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	b = list(map(int, input().split()))
	mx = b[0]
	mn = b[0]
	for x in b:
		if x > mx:
			mx = x
		if x < mn:
			mn = x
	if k == 0:
		for x in b:
			print(end='{} '.format(x))
	elif k % 2:
		for x in b:
			print(end='{} '.format(mx - x))
	else:
		for x in b:
			print(end='{} '.format(x - mn))
	print()


import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	m = max(arr)
	kOdd = [-1 for _ in range(n)]
	for i in range(n):
		kOdd[i] = m - arr[i]
	m2 = max(kOdd)
	kEven = [-1 for _ in range(n)]
	for i in range(n):
		kEven[i] = m2 - kOdd[i]
	if k % 2 == 1:
		print(' '.join([str(x) for x in kOdd]))
	else:
		print(' '.join([str(x) for x in kEven]))


t = int(input())
for case in range(t):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	k -= 1
	d = max(a)
	a = [d - x for x in a]
	d = max(a)
	if k % 2 == 0:
		print(*a)
	else:
		a = [d - x for x in a]
		print(*a)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = [int(i) for i in input().split()][:n]
	(l1, l2) = ([], [])
	maxi = max(l)
	for i in range(n):
		l1.append(maxi - l[i])
	maxi2 = max(l1)
	for i in range(n):
		l2.append(maxi2 - l1[i])
	if k % 2 != 0:
		print(*l1)
	else:
		print(*l2)


import os
import sys
from io import BytesIO, IOBase

def main():
	t = int(input())
	while t:
		(n, k) = map(int, input().split())
		nums = list(map(int, input().split()))
		mini = min(nums)
		maxi = max(nums)
		for i in range(n):
			nums[i] = maxi - nums[i]
		k -= 1
		if k % 2:
			maxi -= mini
			for i in range(n):
				if i == n - 1:
					print(maxi - nums[i])
				else:
					print(maxi - nums[i], end=' ')
		else:
			for i in range(n):
				if i == n - 1:
					print(nums[i])
				else:
					print(nums[i], end=' ')
		t -= 1
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import bisect
import decimal
from decimal import Decimal
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate
decimal.getcontext().prec = 46

def primeFactors(n):
	prime = set()
	while n % 2 == 0:
		prime.add(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			prime.add(i)
			n = n // i
	if n > 2:
		prime.add(n)
	return list(prime)

def getFactors(n):
	factors = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				factors.append(i)
			else:
				factors.append(i)
				factors.append(n // i)
		i = i + 1
	return factors

def modefiedSieve():
	mx = 10 ** 7 + 1
	sieve = [-1] * mx
	for i in range(2, mx):
		if sieve[i] == -1:
			sieve[i] = i
			for j in range(i * i, mx, i):
				if sieve[j] == -1:
					sieve[j] = i
	return sieve

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	num = []
	for p in range(2, n + 1):
		if prime[p]:
			num.append(p)
	return num

def lcm(a, b):
	return a * b // math.gcd(a, b)

def sort_dict(key_value):
	return sorted(key_value.items(), key=lambda kv: (kv[1], kv[0]))

def list_input():
	return list(map(int, input().split()))

def num_input():
	return map(int, input().split())

def string_list():
	return list(input())

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def binaryToDecimal(n):
	return int(n, 2)

def DFS(n, s, adj):
	visited = [False for i in range(n + 1)]
	stack = []
	stack.append(s)
	while len(stack):
		s = stack[-1]
		stack.pop()
		if not visited[s]:
			visited[s] = True
		for node in adj[s]:
			if not visited[node]:
				stack.append(node)

def maxSubArraySum(a, size):
	maxint = 10 ** 10
	max_so_far = -maxint - 1
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far

def solve():
	(n, k) = num_input()
	arr = list_input()
	k = k % 2
	maxx = max(arr)
	maxx1 = 0
	for i in range(n):
		arr[i] = maxx - arr[i]
		maxx1 = max(maxx1, arr[i])
	if k == 1:
		print(*arr)
		return
	for i in range(n):
		arr[i] = maxx1 - arr[i]
	print(*arr)
t = 1
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	m = max(l)
	for i in range(n):
		l[i] = m - l[i]
	a = l[:]
	b = l[:]
	m = max(b)
	for i in range(n):
		b[i] = m - b[i]
	if n == 1:
		print(0)
	elif k % 2 == 0:
		print(*b)
	else:
		print(*a)


from sys import stdin, stdout
import math, sys, heapq
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
from os import path
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def I():
		return int(input())

	def In():
		return map(int, input().split())
else:

	def I():
		return int(stdin.readline())

	def In():
		return map(int, stdin.readline().split())

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_right(a, x)
	if i != len(a):
		return i
	else:
		return -1

def main():
	try:
		(n, k) = In()
		l = list(In())
		t = max(l)
		ma = -1
		for x in range(n):
			l[x] = t - l[x]
			ma = max(ma, l[x])
		k -= 1
		if k & 1 == 1 and k >= 1:
			for x in range(n):
				l[x] = ma - l[x]
			print(*l)
		else:
			print(*l)
	except:
		pass
M = 998244353
P = 1000000007
Inf = 1000000000000000000
for _ in range(I()):
	main()


def solve(n, k, a):
	first = [0] * n
	m = max(a)
	for i in range(n):
		first[i] = m - a[i]
	m = max(first)
	second = [0] * n
	for i in range(n):
		second[i] = m - first[i]
	if k % 2 == 1:
		print(*first)
	else:
		print(*second)
t = int(input())
while t:
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	solve(n, k, a)
	t -= 1


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	v = max(a)
	a1 = []
	for j in range(n):
		a1.append(v - a[j])
	v1 = max(a1)
	a2 = []
	for j in range(n):
		a2.append(v1 - a1[j])
	if k % 2 == 0:
		print(*a2)
	else:
		print(*a1)


t = int(input())
while t > 0:
	t = t - 1
	(n, m) = map(int, input().split())
	k = m
	a = list(map(int, input().split()))
	if len(a) == 1:
		print(0)
	else:
		l = []
		c = max(a)
		for i in range(len(a)):
			l.append(c - a[i])
		g = []
		c = max(l)
		for i in range(len(l)):
			g.append(c - l[i])
		if k % 2 == 0:
			print(*g)
		else:
			print(*l)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	flag = 1
	if k % 2 == 0:
		flag = 2
	for i in range(flag):
		d = max(arr)
		for j in range(len(arr)):
			arr[j] = d - arr[j]
	for i in arr:
		print(i, end=' ')


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if k % 2:
		x = max(a)
		for j in range(n):
			a[j] = x - a[j]
		print(*a)
	else:
		for i in range(2):
			x = max(a)
			for j in range(n):
				a[j] = x - a[j]
		print(*a)


def main():
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	m = max(arr)
	first = []
	for i in range(n):
		first.append(m - arr[i])
	second = []
	m = max(first)
	for i in range(n):
		second.append(m - first[i])
	if k % 2:
		for c in first:
			print(c, end=' ')
	else:
		for c in second:
			print(c, end=' ')
	print('')
for _ in range(int(input())):
	main()


def iter(a):
	m = max(a)
	return [m - a for a in a]
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	if k % 2:
		a = iter(a)
	else:
		for _ in range(2):
			a = iter(a)
	print(*a)


t = int(input())
for tt in range(t):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	m = max(a)
	res = [m - aa for aa in a]
	if (k - 1) % 2 == 0:
		print(' '.join([str(x) for x in res]))
	else:
		m = max(res)
		res = [m - r for r in res]
		print(' '.join([str(x) for x in res]))


import sys
from math import ceil, gcd
from collections import deque
for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	mx = int(-1000000000.0)
	for i in a:
		if i > mx:
			mx = i
	for i in range(len(a)):
		a[i] = mx - a[i]
	mx = -1000000000.0
	for i in a:
		if i > mx:
			mx = i
	for i in range(len(a)):
		if k % 2:
			print(a[i], end=' ')
		else:
			print(mx - a[i], end=' ')
	print()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	maxi = max(a)
	for i in range(n):
		a[i] = maxi - a[i]
	if k == 1:
		print(*a)
		continue
	maxi = max(a)
	for i in range(n):
		a[i] = maxi - a[i]
	if k % 2 == 0:
		print(*a)
	else:
		maxi = max(a)
		for i in range(n):
			a[i] = maxi - a[i]
		print(*a)


import math
import os
import random
import re
import string
from sys import *
from collections import *

def bs(arr, x, l, r):
	if l <= r:
		mid = (r + l) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] > x:
			return bs(arr, x, l, mid - 1)
		else:
			return bs(arr, x, mid + 1, r)
	else:
		return -1

def solve():
	for _ in range(int(input())):
		(n, k) = map(int, stdin.readline().strip().split())
		l = list(map(int, stdin.readline().strip().split()))
		ma = max(l)
		res1 = [0] * n
		for i in range(n):
			res1[i] = ma - l[i]
		res2 = [0] * n
		ma1 = max(res1)
		for i in range(n):
			res2[i] = ma1 - res1[i]
		if k == 1:
			print(*res1)
		elif k == 2:
			print(*res2)
		else:
			k -= 2
			r = k % 2
			if r == 1:
				print(*res1)
			else:
				print(*res2)
solve()


import sys
from collections import defaultdict
t = 1
t = int(input())
for i in range(t):
	(n, k) = list(map(int, sys.stdin.readline().strip().split()))
	a = list(map(int, sys.stdin.readline().strip().split()))
	b = []
	x = max(a)
	for j in range(n):
		b.append(x - a[j])
	c = []
	xx = max(b)
	for j in range(n):
		c.append(xx - b[j])
	if k % 2 == 0:
		print(*c)
	else:
		print(*b)


from sys import stdin, stdout

def find(arr, N, K):
	m = max(arr)
	n = min(arr)
	for i in arr:
		if K % 2:
			print(m - i, end=' ')
		else:
			print(i - n, end=' ')
	print()

def main():
	for _ in range(int(stdin.readline())):
		(N, K) = list(map(int, stdin.readline().split()))
		arr = list(map(int, stdin.readline().split()))
		find(arr, N, K)
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	(x, y) = (min(l), max(l))
	if k % 2 == 0:
		print(' '.join([str(i - x) for i in l]))
	else:
		print(' '.join([str(y - i) for i in l]))


import math
from collections import deque
from sys import stdin, stdout
from string import ascii_letters
input = stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	mx = max(arr)
	farr = [mx - i for i in arr]
	mx = max(farr)
	sarr = [mx - i for i in farr]
	if k % 2:
		print(*farr)
	else:
		print(*sarr)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	lst = list(map(int, input().split()))
	mx = max(lst)
	od = []
	for i in range(n):
		od.append(mx - lst[i])
	mx = max(od)
	ev = []
	for i in range(n):
		ev.append(mx - od[i])
	if k % 2 == 0:
		print(*ev)
	else:
		print(*od)


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	c = list(map(int, input().split()))
	d = max(c)
	e = min(c)
	f = [e, d][b % 2]
	print(*[abs(j - f) for j in c])


t = int(input())
for z in range(t):
	(n, k) = map(int, input().split())
	li = list(map(int, input().split()))
	if k % 2 != 0:
		d = max(li)
		for i in range(n):
			li[i] = d - li[i]
		print(*li)
	elif k % 2 == 0:
		d = max(li)
		for j in range(n):
			li[j] = d - li[j]
		d1 = max(li)
		for q in range(n):
			li[q] = d1 - li[q]
		print(*li)


def solve(n, k, arr):
	ma = max(arr)
	mi = min(arr)
	if k % 2:
		return [ma - a for a in arr]
	else:
		return [a - mi for a in arr]
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	print(*solve(n, k, arr))


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, K, A):
	mx = max(A)
	A = [mx - x for x in A]
	mx = max(A)
	B = [mx - x for x in A]
	if K % 2 == 1:
		return ' '.join(map(str, A))
	return ' '.join(map(str, B))
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
TC = int(input())
for tc in range(1, TC + 1):
	(N, K) = [int(x) for x in input().split()]
	A = [int(x) for x in input().split()]
	ans = solve(N, K, A)
	print(ans)


from sys import stdin

def arr_sum(n, k, arr):
	temp1 = []
	maxx = max(arr)
	for i in range(n):
		temp1.append(maxx - arr[i])
	maxx2 = max(temp1)
	temp2 = []
	for i in range(n):
		temp2.append(maxx2 - temp1[i])
	temp1 = map(str, temp1)
	temp2 = map(str, temp2)
	if k % 2 == 1:
		return ' '.join(temp1)
	else:
		return ' '.join(temp2)
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, stdin.readline().strip().split()))
	print(arr_sum(n, k, arr))


t = int(input())
while t:
	(n, k) = map(int, input().split())
	nl = list(map(int, input().split()))
	maxio = max(nl)
	(arro, arre) = ([], [])
	for i in range(n):
		arro.append(maxio - nl[i])
	maxie = max(arro)
	for i in range(n):
		arre.append(maxie - arro[i])
	if k % 2 == 0:
		print(*arre, sep=' ')
	else:
		print(*arro, sep=' ')
	t -= 1


t = int(input())
for i in range(t):
	(n, k) = map(int, input().strip().split())
	ara = list(map(int, input().strip().split()))
	maxx = max(ara)
	for j in range(n):
		ara[j] = maxx - ara[j]
	if k % 2 == 0:
		maxx1 = max(ara)
		for j in range(n):
			ara[j] = maxx1 - ara[j]
	print(*ara, sep=' ')


def nextInt():
	return int(input())

def intArr():
	arr = input().split(' ')
	return [int(x) for x in arr]

def op(arr, l):
	arr.sort()
	d = arr[l - 1]
	for i in range(0, l):
		arr[i] = d - arr[i]
	return
t = nextInt()
ans = []
for tt in range(t):
	s = intArr()
	length = s[0]
	k = s[1]
	a = intArr()
	if length == 1:
		ans.append(0)
	elif k % 2 == 0:
		for i in range(2):
			d = max(a)
			a = [d - x for x in a]
		b = ''
		for x in range(length):
			if x == length - 1:
				b += str(a[x])
			else:
				b += str(a[x]) + ' '
		ans.append(b)
	else:
		for i in range(3):
			d = max(a)
			a = [d - x for x in a]
		b = ''
		for x in range(length):
			if x == length - 1:
				b += str(a[x])
			else:
				b += str(a[x]) + ' '
		ans.append(b)
for x in ans:
	print(x)


def solve(arr, n, k):
	if k < 5:
		mx = max(arr)
		nm = float('-inf')
		while k:
			for i in range(n):
				arr[i] = mx - arr[i]
				nm = max(nm, arr[i])
			mx = nm
			k -= 1
		return arr
	config2 = []
	config2 += arr
	curr_k = 2
	mx = max(arr)
	nm = float('-inf')
	while curr_k:
		for i in range(n):
			arr[i] = mx - arr[i]
			nm = max(nm, arr[i])
		mx = nm
		curr_k -= 1
	check_same = True
	for i in range(n):
		if arr[i] != config2[i]:
			check_same = False
			break
	if not check_same:
		k -= 1
		mx = max(config2)
		for i in range(n):
			config2[i] = mx - config2[i]
		if k % 2 == 0:
			return config2
		else:
			return arr
	elif k % 2 == 0:
		return config2
	else:
		return arr
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	for val in solve(arr, n, k):
		print(val, end=' ')
	print('\n', end='')


def parr(arr):
	print(*arr, sep=' ')
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	mx = max(a)
	mn = min(a)
	d = mx - mn
	f = list(map(lambda x: mx - x, a))
	s = list(map(lambda x: d - x, f))
	parr(f) if k % 2 == 1 else parr(s)


from collections import *
from sys import *
input = stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	m = max(a)
	b = []
	for i in a:
		b.append(m - i)
	m = max(b)
	c = []
	for i in b:
		c.append(m - i)
	if k % 2 == 1:
		print(*b)
	else:
		print(*c)


T = int(input())

def op(a):
	mx = max(a)
	return [mx - i for i in a]
for Tx in range(T):
	(n, k) = (int(x) for x in input().split(' '))
	a = [int(x) for x in input().split(' ')]
	a = op(a)
	if k % 2 == 0:
		a = op(a)
	print(' '.join([str(x) for x in a]))


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	m = max(a)
	x = [m - i for i in a]
	if k == 1:
		print(*x)
		continue
	m1 = max(x)
	y = [m1 - i for i in x]
	if (k - 1) % 2 == 0:
		print(*x)
	else:
		print(*y)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	mx = max(a)
	ct = 0
	if k & 1:
		for i in range(n):
			a[i] = mx - a[i]
	else:
		while ct < 2:
			mx = max(a)
			for i in range(n):
				a[i] = mx - a[i]
			ct += 1
	print(*a, sep=' ')


import sys
MOD = 10 ** 9 + 7

def power(a, b):
	if b == 0:
		return 1
	if b == 1:
		return a % MOD
	if b % 2 == 1:
		return power(a, b - 1) * a % MOD
	x = power(a, b / 2)
	return x * x % MOD
t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	arr = [int(x) for x in input().split()]
	s = set(arr)
	if len(s) == 1:
		c = [0 for x in range(n)]
		print(*c)
	else:
		s = max(arr)
		a = [s - x for x in arr]
		s = max(a)
		b = [s - x for x in a]
		if k % 2 == 0:
			print(*b)
		else:
			print(*a)
	t -= 1


import sys
input = sys.stdin.readline

def calc(A):
	M = max(A)
	return [M - a for a in A]
t = int(input())
for tests in range(t):
	(n, k) = list(map(int, input().split()))
	A = list(map(int, input().split()))
	if k % 2 == 0:
		k = 2
	else:
		k = 1
	for j in range(k):
		A = calc(A)
	print(*A)


import sys
from math import sqrt, gcd, ceil, log, floor
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
input = sys.stdin.readline
read = lambda : list(map(int, input().strip().split()))
MOD = 10 ** 9 + 7

def main():
	for _ in range(int(input())):
		(n, k) = read()
		arr = read()
		maxi = max(arr)
		arr = [maxi - i for i in arr]
		maxi2 = max(arr)
		arr2 = [maxi2 - i for i in arr]
		k -= 1
		if k % 2:
			print(*arr2)
		else:
			print(*arr)
main()


t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	array = list(map(int, input().split()))
	maxi = max(array)
	array = [maxi - i for i in array]
	maxi = max(array)
	array1 = [maxi - i for i in array]
	maxi = max(array1)
	array2 = [maxi - i for i in array1]
	if k % 2 == 0:
		print(*array1)
	else:
		print(*array2)


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions
from collections import deque, defaultdict, OrderedDict
from fractions import Fraction
from decimal import Decimal

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(ri()):
		(n, k) = ria()
		a = ria()
		f = max(a)
		ans1 = []
		ans2 = []
		g = 0
		for i in range(n):
			a[i] = f - a[i]
			g = max(g, a[i])
		ans1 = a.copy()
		for i in range(n):
			a[i] = g - a[i]
		ans2 = a.copy()
		if k % 2 == 1:
			print(*ans1)
		else:
			print(*ans2)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


import sys
import math
import collections
import heapq
import queue
import itertools
import functools
import operator
import time
readline = sys.stdin.readline
IPS = lambda : readline().rstrip()
IP = lambda : int(readline().rstrip())
MP = lambda : map(int, readline().split())
LS = lambda : list(map(int, readline().split()))

def solve():
	for _ in range(IP()):
		(n, k) = MP()
		arr = LS()
		mx = max(arr)
		for i in range(n):
			arr[i] = mx - arr[i]
		k -= 1
		if k & 1:
			mx = max(arr)
			for i in range(n):
				arr[i] = mx - arr[i]
		for elem in arr:
			print(elem, end=' ')
		print()
solve()


t = int(input())
for i in range(t):
	(n, k) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	high = max(arr)
	arr = [high - x for x in arr]
	high = max(arr)
	k = k - 1
	if k % 2 == 0:
		for j in arr:
			print(j, end=' ')
		print()
	else:
		for j in arr:
			print(high - j, end=' ')
		print()


import sys
import math
import heapq
import collections
fast_reader = sys.stdin.readline
fast_writer = sys.stdout.write

def input():
	return fast_reader().strip()

def print(*argv):
	fast_writer(' '.join((str(i) for i in argv)))
	fast_writer('\n')

def printspace(*argv):
	fast_writer(' '.join((str(i) for i in argv)))
	fast_writer(' ')

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	(n, k) = inputnums()
	a = inputlist()
	mx = -10000000000.0
	for i in range(n):
		mx = max(a[i], mx)
	mx1 = -10000000000.0
	b = []
	for i in range(n):
		b.append(mx - a[i])
		mx1 = max(b[i], mx1)
	if k % 2 == 1:
		print(*b)
		continue
	for i in range(n):
		a[i] = mx1 - b[i]
	print(*a)


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	max1 = max(a)
	min1 = min(a)
	if n == 1:
		print(0)
	elif min1 == max1:
		for i in range(n):
			print(0, end=' ')
		print()
	else:
		t1 = max1 - min1
		if k % 2 == 0:
			for i in a:
				print(t1 - (max1 - i), end=' ')
			print()
		else:
			for i in a:
				print(max1 - i, end=' ')
			print()


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	maxi = max(arr)
	for i in range(n):
		arr[i] = maxi - arr[i]
	if k % 2 == 1:
		print(*arr)
	else:
		maxi = max(arr)
		for i in range(n):
			print(maxi - arr[i], end=' ')


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	d = max(a)
	for i in range(n):
		a[i] = d - a[i]
	even = a.copy()
	d1 = max(even)
	for i in range(n):
		even[i] = d1 - even[i]
	if k % 2 == 1:
		print(*a)
	else:
		print(*even)


def sol():
	(n, k) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	if n == 1:
		return [0]
	if k % 2 == 0:
		for _ in range(2):
			max = float('-inf')
			for el in l:
				if el > max:
					max = el
			for j in range(len(l)):
				l[j] = max - l[j]
		return l
	else:
		for _ in range(1):
			max = float('-inf')
			for el in l:
				if el > max:
					max = el
			for j in range(len(l)):
				l[j] = max - l[j]
		return l
tc = int(input())
for _ in range(tc):
	print(*sol())


def main():
	t = int(input())
	for _ in range(t):
		(n, k) = list(map(int, input().strip().split()))
		a = list(map(int, input().strip().split()))
		maxx = max(a)
		for i in range(n):
			a[i] = maxx - a[i]
		k -= 1
		if k & 1:
			maxx = max(a)
			for i in range(n):
				a[i] = maxx - a[i]
		print(' '.join(list(map(str, a))))
main()


from sys import stdin
for t in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	x = 1
	a = [int(x) for x in stdin.readline().split()]
	if k % 2 == 0:
		x = 2
	for i in range(x):
		k = max(a)
		a = [k - x for x in a]
	print(*a, sep=' ')


t = int(input())
while t != 0:
	(n, k) = [int(x) for x in input().split(' ')]
	arr = [int(x) for x in input().split(' ')]
	maxx = max(arr)
	arr = list(map(lambda x: maxx - x, arr))
	if k % 2 == 1:
		print(' '.join((str(x) for x in arr)))
		t -= 1
		continue
	maxx = max(arr)
	arr = list(map(lambda x: maxx - x, arr))
	print(' '.join((str(x) for x in arr)))
	t -= 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	li = list(map(int, input().split()))
	li1 = []
	li2 = []
	m = max(li)
	if len(li) == 1:
		print(0)
	elif k % 2 == 0:
		for i in li:
			x = m - i
			li1.append(x)
		m1 = max(li1)
		for j in li1:
			x1 = m1 - j
			li2.append(x1)
		for k in li2:
			print(k, end=' ')
		print()
	else:
		for i in li:
			x = m - i
			li1.append(x)
		for k in li1:
			print(k, end=' ')
		print()


t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if k % 2 == 0:
		times = 2
	else:
		times = 1
	for i in range(times):
		d = max(a)
		for i in range(n):
			a[i] = d - a[i]
	print(*a)


for _ in range(int(input())):
	[n, op] = list(map(int, input().split(' ')))
	lst = list(map(int, input().split(' ')))
	d = max(lst)
	lst = [d - i for i in lst]
	if op % 2 == 1:
		print(*lst)
	else:
		d = max(lst)
		print(*[d - i for i in lst])


input = __import__('sys').stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(map(int, input().split()))
	for _ in range((k + 1) % 2 + 1):
		f = max(s)
		for i in range(n):
			s[i] = f - s[i]
	print(*s)


from sys import stdin, stdout
input = stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	m = max(a)
	for i in range(n):
		a[i] = m - a[i]
	k -= 1
	m = max(a)
	for i in range(k % 2):
		for j in range(n):
			a[j] = m - a[j]
	print(*a)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	d = max(l)
	for i in range(n):
		l[i] = d - l[i]
	if m % 2 == 1:
		for i in l:
			print(i, end=' ')
		print()
	else:
		d = max(l)
		for i in range(n):
			l[i] = d - l[i]
		for i in l:
			print(i, end=' ')
		print()


t = int(input())
for _ in range(t):
	(n, k) = [int(i) for i in input().split()]
	f = [int(i) for i in input().split()]
	l = max(f)
	for i in range(n):
		f[i] = l - f[i]
	l = max(f)
	s = [int(i) for i in f]
	for i in range(n):
		s[i] = l - f[i]
	if k % 2 != 0:
		for i in f:
			print(i, end=' ')
		print()
	else:
		for i in s:
			print(i, end=' ')
		print()


a = int(input())
for i in range(a):
	(n, k) = map(int, input().split())
	z = list(map(int, input().split()))
	t = max(z)
	for i in range(len(z)):
		z[i] = t - z[i]
	if k % 2 == 1:
		print(*z)
	else:
		t = max(z)
		for i in range(len(z)):
			z[i] = t - z[i]
		print(*z)


t = int(input())
while t > 0:
	(x, y) = map(int, input().split())
	A = list(map(int, input().split()))
	n = []
	d = max(A)
	for i in range(len(A)):
		A[i] = d - A[i]
	if y % 2 == 1:
		for i in range(len(A)):
			n.append(str(A[i]))
		print(' '.join(n))
	else:
		d = max(A)
		for i in range(len(A)):
			A[i] = d - A[i]
		for i in range(len(A)):
			n.append(str(A[i]))
		print(' '.join(n))
	t -= 1


t = int(input())
ans = []
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	l = []
	d = max(a)
	a = [d - x for x in a]
	l.append(a)
	d = max(a)
	a = [d - x for x in a]
	l.append(a)
	ans.append(l[k & 1 == 0])
for i in ans:
	print(' '.join(map(str, i)))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if k > 5:
		if k % 2 == 0:
			k = 4
		else:
			k = 5

	def f(v):
		m = max(v)
		for i in range(n):
			v[i] = m - v[i]
		return v
	for _ in range(k):
		a = f(a)
	print(*a)


from sys import stdin, stdout

def INPUT():
	return list((int(i) for i in stdin.readline().split()))

def inp():
	return stdin.readline()

def out(x):
	return stdout.write(x)
import math
import random
import sys
for _ in range(int(input())):
	(n, k) = INPUT()
	A = INPUT()
	d = max(A)
	C = []
	for i in range(n):
		C.append(d - A[i])
	D = []
	d = max(C)
	for i in range(n):
		D.append(d - C[i])
	if k % 2 == 0:
		print(*D)
	else:
		print(*C)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	ar = list(map(int, input().split()))
	m = max(ar)
	if k % 2 == 0:
		ar = [m - x for x in ar]
		m = max(ar)
		ar = [m - x for x in ar]
	else:
		ar = [m - x for x in ar]
	print(' '.join(map(str, ar)))


import math
from decimal import Decimal
import heapq
import copy
import heapq
from collections import deque
from collections import defaultdict
MOD = 1000000007

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = map(int, input().split())
	return (n, m)

def da():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	return (n, m, a)

def dva():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def lol(lst, k):
	k = k % len(lst)
	ret = [0] * len(lst)
	for i in range(len(lst)):
		if i + k < len(lst) and i + k >= 0:
			ret[i] = lst[i + k]
		if i + k >= len(lst):
			ret[i] = lst[i + k - len(lst)]
		if i + k < 0:
			ret[i] = lst[i + k + len(lst)]
	return ret

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)

def fact(n):
	tc = []
	ans = {}
	d = 2
	while d * d <= n:
		if n % d == 0:
			tc.append(d)
			n //= d
		else:
			d += 1
	if n > 1:
		tc.append(n)
	for i in tc:
		ans[i] = ans.get(i, 0) + 1
	return ans

def to_zero(n, s):
	lst = s[0]
	ans = []
	for i in range(n):
		if lst == s[i]:
			continue
		elif lst == '0':
			lst = '1'
			ans.append(i)
		else:
			lst = '0'
			ans.append(i)
	if lst == '1':
		ans.append(n)
	return ans
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	d = max(a)
	k -= 1
	a = [d - i for i in a]
	if k == 0:
		print(*a)
	else:
		if k % 2:
			d = max(a)
			a = [d - i for i in a]
		print(*a)


import math
testcases = int(input())
while testcases > 0:
	(n, k) = map(int, input().split())
	myArray = list(map(int, input().split()))
	maxElement = max(myArray)
	myList1 = []
	myList2 = []
	for i in range(len(myArray)):
		myArray[i] = maxElement - myArray[i]
		myList1.append(myArray[i])
	maxElement = max(myArray)
	for i in range(len(myArray)):
		myArray[i] = maxElement - 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


T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	maxx = max(a)
	minn = min(a)
	tr = maxx - minn
	if k % 2 == 1:
		for i in range(n):
			a[i] = maxx - a[i]
	else:
		for i in range(n):
			a[i] = tr - maxx + a[i]
	print(*a)


import os
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from io import BytesIO, IOBase
from itertools import accumulate, combinations, combinations_with_replacement, groupby, permutations, product
from math import acos, asin, atan, ceil, cos, degrees, factorial, hypot, inf, log2, pi, radians, sin, sqrt, tan
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits

def inp():
	return int(input())

def inlist():
	return list(map(int, input().split()))

def instr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())

def main():
	t = inp()
	for _ in range(t):
		(n, k) = invr()
		a = inlist()
		mx = max(a)
		for i in range(n):
			a[i] = mx - a[i]
		b = []
		mx = max(a)
		for i in range(n):
			b.append(mx - a[i])
		if k % 2 != 0:
			print(*a)
		else:
			print(*b)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


def read_int():
	n = int(input())
	return n

def read_ints():
	ints = [int(x) for x in input().split(' ')]
	return ints

def solve(n, k, a):
	if k % 2 == 0:
		m = 2
	else:
		m = 1
	for i in range(m):
		mx = max(a)
		a = [mx - x for x in a]
	sol = [str(x) for x in a]
	return sol
t = read_int()
for case in range(t):
	(n, k) = read_ints()
	a = read_ints()
	sol = solve(n, k, a)
	print(' '.join(sol))


t = int(input())
while t:
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	if k % 2 == 0:
		for i in range(2):
			m = max(l)
			for j in range(len(l)):
				l[j] = m - l[j]
	else:
		for i in range(1):
			m = max(l)
			for j in range(len(l)):
				l[j] = m - l[j]
	print(*l)
	t = t - 1


from math import *
from collections import *
from random import *
from decimal import Decimal
from heapq import *
from bisect import *
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 5)

def lis():
	return list(map(int, input().split()))

def ma():
	return map(int, input().split())

def inp():
	return int(input())

def st1():
	return input().rstrip('\n')
t = inp()
while t:
	t -= 1
	(n, k) = ma()
	a = lis()
	x = max(a)
	z = min(a)
	if k % 2 == 0:
		for i in range(n):
			a[i] -= z
	else:
		for i in range(n):
			a[i] = x - a[i]
	print(*a)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	d = 0
	d = max(a)
	for i in range(n):
		a[i] = d - a[i]
	if k % 2 != 0:
		print(' '.join(map(str, a)))
	else:
		d = max(a)
		for i in range(n):
			a[i] = d - a[i]
		print(' '.join(map(str, a)))


def solve():
	(n, k) = map(int, input().split())
	l = [int(x) for x in input().split()]
	c = [0] * n
	m = max(l)
	for i in range(n):
		l[i] = m - l[i]
	m = max(l)
	for i in range(n):
		c[i] = m - l[i]
	if k % 2 == 0:
		print(*c)
	else:
		print(*l)
for _ in range(int(input())):
	solve()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	d = max(l)
	l1 = [d - i for i in l]
	d = max(l1)
	l2 = [d - i for i in l1]
	if k % 2 == 1:
		print(*l1)
	else:
		print(*l2)


from collections import deque
from collections import OrderedDict
import math
import sys
import os
import threading
import bisect
import operator
import heapq
from atexit import register
from io import BytesIO
import io
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	lis = list(map(int, input().split()))
	maxE = max(lis)
	lis2 = [0] * n
	for i in range(n):
		lis[i] = maxE - lis[i]
		lis2[i] = lis[i]
	maxE2 = max(lis)
	for i in range(n):
		lis2[i] = maxE2 - lis[i]
	if k % 2 == 1:
		print(*lis, sep=' ')
	else:
		print(*lis2, sep=' ')
sys.exit(0)

class Person:

	def __init__(self, name, age):
		self.name = name
		self.age = age
p1 = Person('heelo', 27)
print(help(Person))
age = 26
name = 'Swaroop'
print('Возрас {} -- {} лет'.format(name, age))
print(help(object))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	s = [int(i) for i in input().split()]
	a = max(s)
	(s1, s2) = ([], [])
	for i in range(n):
		s1.append(a - s[i])
	if k % 2 == 1:
		print(*s1)
	else:
		a = max(s1)
		for i in range(n):
			s2.append(a - s1[i])
		print(*s2)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(o) for o in input().split()]
	ans = [a[:]]
	si = 0
	while True:
		a1 = a[:]
		ma = max(a1)
		for i in range(n):
			a1[i] = ma - a1[i]
		if a1 in ans:
			si = ans.index(a1)
			break
		else:
			ans.append(a1[:])
		a = a1[:]
	if k < si:
		print(*ans[k])
	else:
		ind = si + (k - si) % (len(ans) - si)
		print(*ans[ind])


def solve(m, l):
	if m[1] % 2 == 0:
		ele = 2
	else:
		ele = 1
	for i in range(ele):
		maxi = max(l)
		for i in range(len(l)):
			l[i] = maxi - l[i]
	print(' '.join(map(str, l)))
n = int(input())
for i in range(n):
	m = list(map(int, input().split()))
	l = list(map(int, input().split()))
	solve(m, l)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	temp = max(a)
	for i in range(n):
		a[i] = temp - a[i]
	temp = max(a)
	b = [0 for i in range(n)]
	for i in range(n):
		b[i] = temp - a[i]
	if k == 1:
		print(' '.join(map(str, a)))
	elif k % 2 == 0:
		print(' '.join(map(str, b)))
	else:
		print(' '.join(map(str, a)))


import sys
input = sys.stdin.readline
from bisect import bisect_left
from bisect import bisect_right
from math import ceil, factorial

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
for _ in range(int(input())):
	(n, k) = int_array()
	a = int_array()
	d = max(a)
	for i in range(n):
		a[i] = d - a[i]
	k -= 1
	if k % 2:
		d = max(a)
		for i in range(n):
			a[i] = d - a[i]
	print(*a)


def operate(l: list, k: int) -> list:
	if k % 2:
		m = max(l)
		for i in range(len(l)):
			l[i] = m - l[i]
	else:
		for i in range(2):
			m = max(l)
			for j in range(len(l)):
				l[j] = m - l[j]
	return l
t = int(input())
while t:
	(i, m) = [int(i) for i in input().split()]
	l = [int(i) for i in input().split()]
	ans = operate(l, m)
	for i in ans:
		print(i, end=' ')
	t -= 1


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	ar = list(map(int, input().split()))
	maxx = max(ar)
	for i in range(n):
		ar[i] = maxx - ar[i]
	ar1 = ar[:]
	maxxx = max(ar)
	for i in range(n):
		ar[i] = maxxx - ar[i]
	ar2 = ar[:]
	if k % 2 == 0:
		print(*ar2)
	else:
		print(*ar1)


import random

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	c = 0
	f = 0
	for i in range(10):
		c += 1
		maxx = max(a)
		for j in range(n):
			a[j] = maxx - a[j]
		if c == k:
			f = 1
			for i in a:
				print(i, end=' ')
	k -= 10
	if f == 0:
		if k % 2 == 0:
			for i in a:
				print(i, end=' ')
		else:
			maxx = max(a)
			for j in range(n):
				a[j] = maxx - a[j]
			for i in a:
				print(i, end=' ')
	print('')


for _ in range(int(input())):
	(n, k) = map(int, input().split(' '))
	arr = [int(num) for num in input().split(' ')]
	if k % 2 != 0:
		d = max(arr)
		for i in range(n):
			arr[i] = d - arr[i]
			print(arr[i], end=' ')
		print('')
	else:
		d = max(arr)
		for i in range(n):
			arr[i] = d - arr[i]
		d = max(arr)
		for i in range(n):
			arr[i] = d - arr[i]
			print(arr[i], end=' ')
		print('')


import math
import sys
import itertools
import random
import bisect
import heapq
import collections

def lcm(x, y):
	return x * y // math.gcd(x, y)

def hcf(x, y):
	return math.gcd(x, y)

def primes(n):
	prime = [True for _ in range(0, n + 1)]
	res = []
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[p] = False
		p += 1
	for i in range(0, n + 1):
		if prime[i] == True:
			res.append(i)
	return res

def primeFactors(n):
	res = []
	while n % 2 == 0:
		res.append(2)
		n //= 2
	for i in range(3, math.sqrt(n) + 1, 2):
		while n % i == 0:
			res.append(i)
			n //= i
	if n > 2:
		res.append(n)
	return res
for _ in range(0, int(input())):
	(n, k) = map(int, input().strip().split())
	l = list(map(int, input().strip().split()))
	odd = []
	even = []
	d = max(l)
	for i in l:
		odd.append(d - i)
	d = max(odd)
	for i in odd:
		even.append(d - i)
	if k % 2 == 0:
		print(*even)
	else:
		print(*odd)


from sys import stdin, stdout
from itertools import combinations
from collections import defaultdict, Counter
import math

def listIn():
	return list(map(int, stdin.readline().strip().split()))

def stringListIn():
	return [x for x in stdin.readline().split()]

def intIn():
	return int(stdin.readline())

def stringIn():
	return stdin.readline().strip()
t = intIn()
while t > 0:
	t -= 1
	(n, k) = listIn()
	a = listIn()
	val = 2
	li = []
	while val > 0:
		val -= 1
		m = max(a)
		a = [m - i for i in a]
		li.append(a)
	if k % 2 == 0:
		print(*li[1])
	else:
		print(*li[0])


t = int(input())
while t:
	inp1 = list(map(int, input().strip().split()))[:2]
	(n, k) = (inp1[0], inp1[1])
	a = list(map(int, input().strip().split()))[:n]
	if k % 2:
		for i in range(1):
			max1 = max(a)
			for j in range(len(a)):
				a[j] = max1 - a[j]
		for i in a:
			print(i, end=' ')
	else:
		for i in range(2):
			max1 = max(a)
			for j in range(len(a)):
				a[j] = max1 - a[j]
		for i in a:
			print(i, end=' ')
	t -= 1


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	L = list(map(int, input().split()))
	m = max(L)
	for i in range(n):
		L[i] = m - L[i]
	k = k - 1
	if k % 2 == 1:
		m = max(L)
		for i in range(n):
			L[i] = m - L[i]
	for i in L:
		print(i, end=' ')
	print()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split(' '))
	arr = list(map(int, input().split(' ')))
	d = max(arr)
	for i in range(len(arr)):
		arr[i] = d - arr[i]
	k -= 1
	d = max(arr)
	if k > 0:
		k %= 2
		if k == 1:
			for i in range(len(arr)):
				arr[i] = d - arr[i]
	for num in arr:
		print(num, end=' ')
	print()


t = int(input())
while t:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	d = max(a)
	b = []
	p = []
	for i in range(n):
		a[i] = d - a[i]
	b = a[:]
	d = max(a)
	for i in range(n):
		a[i] = d - a[i]
	if k % 2 == 0:
		for i in range(n - 1):
			print(a[i], end=' ')
		print(a[n - 1])
	else:
		for i in range(n - 1):
			print(b[i], end=' ')
		print(b[n - 1])
	t -= 1


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if k % 2 != 0:
		max_elem = max(a)
		a = [max_elem - x for x in a]
	else:
		max_elem = max(a)
		a = [max_elem - x for x in a]
		max_elem = max(a)
		a = [max_elem - x for x in a]
	for _ in a:
		print(_, end=' ')


import sys

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def rinput():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
mod = int(1000000000.0) + 7
for _ in range(iinput()):
	(n, k) = rinput()
	a = get_list()
	d = max(a)
	for i in range(n):
		a[i] = d - a[i]
	if k % 2 == 0:
		d = max(a)
		for i in range(n):
			a[i] = d - a[i]
	print(*a)


import sys, io, os
BUFSIZE = 8192

class FastIO(io.IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = io.BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(io.IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
T = int(input())
for _ in range(T):
	(N, K) = map(int, input().split())
	A = list(map(int, input().split()))
	ma = max(A)
	mi = min(A)
	if K % 2:
		A = [ma - a for a in A]
	else:
		A = [a - mi for a in A]
	print(' '.join(map(str, A)))


from sys import stdin
import math
inp = lambda : stdin.readline().strip()
t = int(inp())
for _ in range(t):
	(n, k) = [int(x) for x in inp().split()]
	a = [int(x) for x in inp().split()]
	kEven = []
	kOdd = []
	maxi = max(a)
	for i in a:
		kEven.append(maxi - i)
	maxi = max(kEven)
	for i in kEven:
		kOdd.append(maxi - i)
	if k % 2 == 1:
		print(*kEven)
	else:
		print(*kOdd)


t = int(input())
for _ in range(t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	a = list(map(int, input().split()))
	d = max(a)
	t1 = [d - i for i in a]
	d = max(t1)
	t2 = [d - i for i in t1]
	if k % 2 == 1:
		res = t1
	else:
		res = t2
	for i in res:
		print(i, end=' ')
	print()


from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))

def solve():
	(n, k) = get_tuple()
	ls = get_list()
	(mini, maxi) = (min(ls), max(ls))
	if mini < 0:
		k -= 1
		for i in range(n):
			ls[i] = maxi - ls[i]
	if k > 0:
		cnt_z = ls.count(0)
		if cnt_z == 0:
			k -= 1
			d = max(ls)
			for i in range(n):
				ls[i] = d - ls[i]
	if k % 2:
		d = max(ls)
		for i in range(n):
			ls[i] = d - ls[i]
	print(*ls)

def main():
	solve()
TestCases = True
if TestCases:
	for i in range(get_int()):
		main()
else:
	main()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	if k % 2 == 1:
		k = 1
	else:
		k = 2
	for i in range(k):
		ma = max(l)
		for i in range(0, len(l)):
			l[i] = ma - l[i]
	print(*l)


ls = lambda : list(map(int, input().split()))
ip = lambda : int(input())
sip = lambda : input()
r = lambda a: range(a)
lcm = lambda a, b: abs(a * b) // math.gcd(a, b)
t = ip()
for _ in r(t):
	(num, k) = ls()
	elements = ls()
	m1 = max(elements)
	elements = [m1 - i for i in elements]
	if k % 2 != 0:
		print(*elements, end=' ')
		print('')
	else:
		m = max(elements)
		elements = [m - i for i in elements]
		print(*elements, end=' ')
		print('')


t = int(input())
for i in range(t):
	(n, o) = map(int, input().split(' '))
	l = list(map(int, input().split(' ')))
	m = max(l)
	l1 = [m - i for i in l]
	m1 = max(l1)
	l2 = [m1 - i for i in l1]
	if o % 2 == 0:
		print(' '.join(map(str, l2)))
	else:
		print(' '.join(map(str, l1)))


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	ar = list(map(int, input().split()))
	k -= 1
	M = max(ar)
	m = min(ar)
	x = M - m
	for i in range(n):
		ar[i] = M - ar[i]
	if k % 2 == 0:
		print(*ar)
	else:
		for i in range(n):
			ar[i] = x - ar[i]
		print(*ar)


from math import *
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	p = max(a)
	for i in range(n):
		a[i] = p - a[i]
	r = a.copy()
	if k % 2 != 0:
		print(*a)
	else:
		p = max(a)
		for i in range(n):
			a[i] = p - a[i]
		print(*a)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	m = max(arr)
	for i in range(n):
		arr[i] = m - arr[i]
	if k % 2 != 0:
		for i in arr:
			print(i, end=' ')
	else:
		m = max(arr)
		for i in range(n):
			print(m - arr[i], end=' ')
	print()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	for j in range(2 + k % 2):
		maxi = max(l)
		for i in range(n):
			l[i] = maxi - l[i]
	print(' '.join(map(str, l)))


for test in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	k %= 2
	k += 2
	while k > 0:
		m = max(arr)
		for i in range(n):
			arr[i] = m - arr[i]
		k -= 1
	print(*arr)


II = lambda : list(map(int, input().split()))
for i in range(int(input())):
	(n, k) = II()
	A = II()
	M1 = max(A)
	B1 = [M1 - val for val in A]
	M2 = max(B1)
	B2 = [M2 - val for val in B1]
	if k % 2 == 1:
		print(*B1)
	else:
		print(*B2)


def operation(itrb, max_e):
	return list(map(lambda i: max_e - i, itrb))
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	sequence = input()
	sequence = [int(i) for i in sequence.split()]
	max_e = max(sequence)
	sequence = operation(sequence, max_e)
	if k % 2 == 0:
		max_e = max(sequence)
		sequence = operation(sequence, max_e)
	print(' '.join(map(str, sequence)))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	d = max(l)
	ar = [d - i for i in l]
	k -= 1
	if k % 2 == 0:
		print(*ar)
	else:
		f = max(ar)
		print(*[f - i for i in ar])


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list()
	k = max(a)
	if y % 2 != 0:
		for i in range(x):
			a[i] = k - a[i]
	else:
		for i in range(2):
			k = max(a)
			for j in range(x):
				a[j] = k - a[j]
	for i in a:
		print(i, end=' ')
	print()


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	max_a = max(a)
	for i in range(n):
		a[i] = max_a - a[i]
	max_a = max(a)
	if k % 2 == 0:
		for i in range(n):
			a[i] = max_a - a[i]
	print(*a)


for ik in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	ma = max(l)
	if k % 2 == 1:
		l = [ma - l[i] for i in range(n)]
	else:
		l = [ma - l[i] for i in range(n)]
		ma = max(l)
		l = [ma - l[i] for i in range(n)]
	print(*l)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(map(int, input().split()))
	ma = max(s)
	for i in range(n):
		s[i] = ma - s[i]
	if k % 2:
		print(*s)
	else:
		ma = max(s)
		for i in range(n):
			s[i] = ma - s[i]
		print(*s)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	if k % 2 != 0:
		p = max(l)
		for i in range(len(l)):
			l[i] = p - l[i]
	else:
		for i in range(2):
			p = max(l)
			for i in range(len(l)):
				l[i] = p - l[i]
	print(*l)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	mx = -1000000000000
	for i in range(n):
		mx = max(mx, arr[i])
	mx2 = -1000000000000
	for i in range(n):
		arr[i] = mx - arr[i]
		mx2 = max(arr[i], mx2)
	if k % 2 != 0:
		for i in range(n):
			print(arr[i], end=' ')
		continue
	else:
		for i in range(n):
			arr[i] = mx2 - arr[i]
			print(arr[i], end=' ')


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	s = max(a)
	t = min(a)
	ans = []
	if k % 2 == 0:
		for i in range(n):
			ans.append(str(a[i] - t))
	else:
		for i in range(n):
			ans.append(str(s - a[i]))
	print(' '.join(ans))


import sys
from collections import defaultdict as dd
from collections import deque
from functools import *
from fractions import Fraction as f
from copy import *
from bisect import *
from heapq import *
from math import *
from itertools import permutations

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')

def inc(d, c):
	d[c] = d[c] + 1 if c in d else 1

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for xx in input().split()]

def fi():
	return int(input())

def pro(a):
	return reduce(lambda a, b: a * b, a)

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def gh():
	sys.stdout.flush()

def isvalid(i, j):
	return 0 <= i < n and 0 <= j < n

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)
t = fi()
mod = 10 ** 9 + 7
while t > 0:
	t -= 1
	(n, k) = mi()
	a = li()
	d = max(a)
	p = []
	q = []
	for i in range(n):
		p.append(d - a[i])
	d = max(p)
	for i in range(n):
		q.append(d - p[i])
	if k % 2 == 0:
		print(*q)
	else:
		print(*p)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	list1 = list((int(n) for n in input().split()))
	m1 = max(list1)
	while k > 0:
		list2 = []
		m1 = max(list1)
		temp = list1[:]
		for i in range(n):
			list2.append(m1 - list1[i])
		m = max(list2)
		list1 = list2[:]
		if m == m1 and k != 1:
			if k % 2 == 0:
				list1 = temp[:]
			break
		else:
			k -= 1
	print(*list1)


t = int(input())
while t > 0:
	(n, k) = [int(x) for x in input().split()]
	l = list(map(int, input().split()))
	p = max(l)
	for i in range(n):
		l[i] = p - l[i]
	p = max(l)
	l1 = []
	for i in range(n):
		l1.append(p - l[i])
	if k % 2 == 0:
		print(*l1)
	else:
		print(*l)
	t -= 1


import collections

def solve(lst, k):
	if k == 0:
		return lst
	mx = max(lst)
	ans = [i for i in lst]
	ans2 = [i for i in lst]
	for i in range(len(lst)):
		ans[i] = mx - lst[i]
	mx2 = max(ans)
	for i in range(len(ans)):
		ans2[i] = mx2 - ans[i]
	if k % 2 == 0:
		return ' '.join([str(i) for i in ans2])
	return ' '.join([str(i) for i in ans])

def sort(key):
	return key[0]
ans = []
n = int(input())
for i in range(n):
	(m, k) = map(int, input().split())
	lst = list(map(int, input().split()))
	ans.append(solve(lst, k))
for i in ans:
	print(i)


t = int(input())
for i in range(1, t + 1):
	l = input().split()
	n = int(l[0])
	k = int(l[1])
	l = input().split()
	l = [int(i) for i in l]
	maximum = max(l)
	l_new = [maximum - i for i in l]
	l.clear()
	maximum = max(l_new)
	l_new = [maximum - i for i in l_new]
	if k % 2 == 0:
		print(*l_new)
		l_new.clear()
	else:
		l_new = [maximum - i for i in l_new]
		print(*l_new)
		l_new.clear()


for i in range(int(input())):
	(n, k) = map(int, input().split())
	l = [int(x) for x in input().split()]
	a = max(l)
	for i in range(n):
		l[i] = a - l[i]
	if k % 2 == 0:
		a = max(l)
		for i in range(n):
			l[i] = a - l[i]
		print(*l)
	else:
		print(*l)


t = int(input())
for _ in range(t):
	n = list(map(int, input().split()))
	a = list(map(int, input().split()))
	d = max(a)
	for i in range(n[0]):
		a[i] = d - a[i]
	if n[1] % 2 != 0:
		print(*a)
	else:
		d = max(a)
		for i in range(n[0]):
			a[i] = d - a[i]
		print(*a)


from functools import reduce
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def arr():
	return [int(i) for i in input().split()]

def sarr():
	return [int(i) for i in input()]

def inn():
	return int(input())
mo = 1000000007
for _ in range(int(input())):
	(n, k) = value()
	a = arr()
	mn = min(a)
	if mn == 0:
		mx = max(a)
		if k % 2 == 0:
			print(*a)
		else:
			for i in range(n):
				a[i] = mx - a[i]
			print(*a)
	else:
		mx = max(a)
		if k % 2 == 0:
			for i in range(n):
				a[i] = a[i] - mn
			print(*a)
		else:
			for i in range(n):
				a[i] = mx - a[i]
			print(*a)


for case in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	if k % 2 == 1:
		d = max(a)
		for i in range(n):
			a[i] = d - a[i]
	elif k % 2 == 0:
		d = max(a)
		for i in range(n):
			a[i] = d - a[i]
		d = max(a)
		for i in range(n):
			a[i] = d - a[i]
	print(*a)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = [int(a) for a in input().split()]
	m = max(l)
	l = [m - a for a in l]
	if k % 2 == 0:
		m = max(l)
		l = [m - a for a in l]
	print(*l)


n = int(input())
for i in range(n):
	(x, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	if k % 2 == 0:
		k = 2
		while k > 0:
			mx = max(arr)
			for j in range(x):
				arr[j] = mx - arr[j]
			k = k - 1
		for c in arr:
			print(c, end=' ')
		print('')
	else:
		k = 1
		while k > 0:
			mx = max(arr)
			for j in range(x):
				arr[j] = mx - arr[j]
			k = k - 1
		for c in arr:
			print(c, end=' ')
		print('')


t = int(input())
for row in range(0, t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	for times in range(0, 1 + (k + 1) % 2):
		maxi = max(a)
		for i in range(len(a)):
			a[i] = maxi - a[i]
	print(*a)


for _ in range(int(input())):
	(n, k) = map(int, input().strip().split())
	arr = list(map(int, input().strip().split()))
	d = max(arr)
	odd = []
	even = []
	for x in range(n):
		odd.append(d - arr[x])
	new_max = max(odd)
	for y in range(n):
		even.append(new_max - odd[y])
	if k % 2:
		print(*odd)
	else:
		print(*even)


import sys
input = sys.stdin.readline
for f in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	mx = max(a)
	mx2 = 0
	for i in range(n):
		a[i] = mx - a[i]
		mx2 = max(a[i], mx2)
	if k % 2 == 0:
		for i in range(n):
			a[i] = mx2 - a[i]
	print(*a)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ar = list(map(int, input().split()))
	c1 = []
	ma = max(ar)
	for i in range(n):
		c1.append(ma - ar[i])
	c2 = []
	ma = max(c1)
	for i in range(n):
		c2.append(ma - c1[i])
	if k % 2 == 0:
		print(*c2)
	else:
		print(*c1)


import copy

def honest(arr):
	d = max(arr)
	return [d - x for x in arr]

def solve():
	(n, k) = (int(x) for x in input().split())
	arr = [int(x) for x in input().split()]
	after1 = honest(arr)
	after2 = honest(after1)
	v1 = copy.copy(arr)
	states = [after1, after2]
	v2 = states[(k + 1) % 2]
	print(*v2)
for _ in range(int(input())):
	solve()


m = int(input())
for j in range(m):
	(a, b) = input().split(' ')
	e = []
	if int(b) % 2 == 0:
		c = list(map(int, input().split(' ')))
		d = max(c)
		for i in c:
			e.append(d - i)
		f = max(e)
		for j in e:
			print(f - j, end=' ')
		print()
	else:
		c = list(map(int, input().split(' ')))
		d = max(c)
		for i in c:
			print(d - i, end=' ')
		print()


t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	max = a[0]
	for e in a:
		if e >= max:
			max = e
	d = max
	s = []
	for j in range(n):
		x = d - a[j]
		s.append(x)
	max = s[0]
	for y in s:
		if y >= max:
			max = y
	u = max
	z = []
	for j in range(n):
		w = u - s[j]
		z.append(w)
	if k % 2 == 0:
		print(str(z).replace('[', '').replace(']', '').replace(',', ''))
	else:
		print(str(s).replace('[', '').replace(']', '').replace(',', ''))


t = int(input())
while t:
	x = []
	line = input()
	(n, k) = line.split()
	n = int(n)
	k = int(k)
	tmp = input()
	x = tmp.split()
	x = list(map(int, x))
	mini = min(x)
	maxi = max(x)
	for i in range(len(x)):
		x[i] = maxi - x[i]
	for i in range(len(x)):
		if k & 1:
			print(x[i], end=' ')
		else:
			print(maxi - mini - x[i], end=' ')
	print()
	t -= 1


q = int(input())
for _ in range(q):
	(n, k) = map(int, input().split())
	dat = map(int, input().split())
	dat = list(dat)
	res = []
	import copy
	for i in range(3):
		l = copy.deepcopy(dat)
		res.append(l)
		ma = max(dat)
		dat = map(lambda x: ma - x, dat)
		dat = list(dat)
	print(' '.join(list(map(str, res[1 + (k + 1) % 2]))))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	maxi = max(l)
	if k % 2 == 0:
		for i in range(n):
			l[i] = maxi - l[i]
		maxi = max(l)
		for i in l:
			print(maxi - i, end=' ')
		print()
	else:
		for i in l:
			print(maxi - i, end=' ')
		print()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	array = list(map(int, input().split()))
	maximum = max(array)
	ar2 = []
	ar3 = []
	for i in range(n):
		ar2.append(maximum - array[i])
	maximum = max(ar2)
	for i in range(n):
		ar3.append(maximum - ar2[i])
	if k % 2 == 1:
		print(' '.join(map(str, ar2)))
	else:
		print(' '.join(map(str, ar3)))


for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = []
	c = []
	m = max(a)
	for i in range(len(a)):
		b.append(m - a[i])
	m = max(b)
	for i in range(len(b)):
		c.append(m - b[i])
	if k % 2 == 0:
		print(*c)
	else:
		print(*b)


t = int(input())
for i in range(0, t):
	(n, k) = list(map(int, input().split()))
	arr = []
	even = []
	odd = []
	mx = -1000000000
	mx1 = -1000000000
	arr1 = input()
	arr1 = arr1.split()
	for j in range(0, n):
		x = int(arr1[j])
		arr.append(x)
		if x > mx:
			mx = x
	for j in range(0, n):
		diff = mx - arr[j]
		odd.append(diff)
		if diff > mx1:
			mx1 = diff
	for j in range(0, n):
		diff = mx1 - odd[j]
		even.append(diff)
	if k % 2 == 0:
		for j in range(0, n):
			print(even[j], end=' ')
		print()
	if k % 2 == 1:
		for j in range(0, n):
			print(odd[j], end=' ')
		print()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	d1 = max(a)
	ao = [d1 - i for i in a]
	d2 = max(ao)
	ae = [d2 - j for j in ao]
	if k % 2 == 0:
		print(*ae)
	else:
		print(*ao)


from sys import stdin, stdout
test_cases = int(stdin.readline())
for _ in range(test_cases):
	(n, k) = map(int, stdin.readline().split())
	arr_a = list(map(int, stdin.readline().split()))
	for i in range(1, k + 1):
		max_a = max(arr_a)
		for j in range(n):
			arr_a[j] = max_a - arr_a[j]
		if i % 2 == k % 2:
			break
	s = ''
	for i in arr_a:
		s += str(i) + ' '
	stdout.write(s)
	stdout.write('\n')


for _ in range(int(input())):
	(n, k) = map(int, input().strip().split())
	val = list(map(int, input().strip().split()))
	i = 0
	max_val = max(val)
	if k % 2:
		val = [max_val - i for i in val]
		print(*val)
	else:
		val = [max_val - i for i in val]
		max_val = max(val)
		val = [max_val - i for i in val]
		print(*val)


t = int(input())
for _ in range(t):
	l1 = [int(x) for x in input().split()]
	(n, k) = (l1[0], l1[1])
	l2 = [int(x) for x in input().split()]
	for i in range(k % 2 + 2):
		new = max(l2)
		l2 = [new - x for x in l2]
	print(*l2)


import sys
input = sys.stdin.readline

def print(val):
	sys.stdout.write(str(val) + '\n')

def prog():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		a = list(map(int, input().split()))
		a2 = [0] * n
		mx = max(a)
		for i in range(n):
			a[i] = mx - a[i]
		mx = max(a)
		for i in range(n):
			a2[i] = mx - a[i]
		if k % 2 == 0:
			print(' '.join(map(str, a2)))
		else:
			print(' '.join(map(str, a)))
prog()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	d = max(a)
	l = list(map(lambda x: d - x, a))
	d1 = max(l)
	l1 = list(map(lambda x: d1 - x, l))
	if (k - 1) % 2 == 0:
		print(*l)
	else:
		print(*l1)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	d = max(a)
	ans1 = []
	ans2 = []
	for i in range(n):
		ans1.append(d - a[i])
	d = max(ans1)
	for i in range(n):
		ans2.append(d - ans1[i])
	if k % 2 == 1:
		print(' '.join(map(str, ans1)))
	else:
		print(' '.join(map(str, ans2)))


t = int(input())
for abc in range(t):
	(num, numberOftimes) = list(map(int, input().split()))
	myList = list(map(int, input().split()))
	if numberOftimes == 0 or numberOftimes == 1 or numberOftimes == 2:
		for i in range(numberOftimes):
			max1 = max(myList)
			myList = list(map(lambda x: max1 - x, myList))
		print(*myList)
	else:
		max1 = max(myList)
		firstArr = list(map(lambda x: max1 - x, myList))
		max2 = max(firstArr)
		secondArr = list(map(lambda x: max2 - x, firstArr))
		if numberOftimes & 1 == 0:
			print(*secondArr)
		else:
			print(*firstArr)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(map(int, input().split()))
	m = -10 ** 9
	o = -m
	for elem in s:
		m = max(m, elem)
		o = min(o, elem)
	for i in range(n):
		s[i] = m - s[i]
	for i in range((k - 1) % 2):
		m -= o
		for i in range(n):
			s[i] = m - s[i]
	print(str(s)[1:-1].replace(',', ''))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	first = list(map(int, input().split()))
	k -= 1
	m = max(first)
	for i in range(n):
		first[i] = m - first[i]
	second = first.copy()
	m = max(second)
	for i in range(n):
		second[i] = m - second[i]
	if k % 2 == 0:
		print(*first)
	else:
		print(*second)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	if k % 2 == 0:
		mn = min(arr)
		for j in range(n):
			arr[j] = arr[j] - mn
	else:
		mx = max(arr)
		for j in range(n):
			arr[j] = mx - arr[j]
	print(*arr)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	first_d = max(a)
	second_a = []
	for i in range(n):
		second_a.append(first_d - a[i])
	second_d = max(second_a)
	third_a = []
	for i in range(n):
		third_a.append(second_d - second_a[i])
	if k % 2:
		print(' '.join([str(n) for n in second_a]))
	else:
		print(' '.join([str(n) for n in third_a]))


t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	max1 = max(a)
	ans1 = [max1 - a[i] for i in range(n)]
	max2 = max(ans1)
	ans2 = [max2 - ans1[i] for i in range(n)]
	if k % 2:
		print(*ans1)
	else:
		print(*ans2)


t = int(input())
for i in range(t):
	(n, k) = [int(item) for item in input().split()]
	a = list(map(int, input().split()))
	d = max(a)
	for l in range(n):
		a[l] = d - a[l]
	d = max(a)
	if k % 2 != 0:
		pass
	else:
		for l in range(n):
			a[l] = d - a[l]
	for l in range(n):
		if l == n - 1:
			print(a[l])
		else:
			print(a[l], end=' ')


t = int(input())

def solve(n, k, a):
	ma = max(a)
	odd_a = [ma - aa for aa in a]
	max_odd_a = max(odd_a)
	even_a = [max_odd_a - e for e in odd_a]
	if k % 2 == 1:
		print(*odd_a)
		return
	else:
		print(*even_a)
		return
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	solve(n, k, a)


import sys
input = sys.stdin.readline
(inp, ip) = (lambda : int(input()), lambda : [int(w) for w in input().split()])
for _ in range(inp()):
	(n, k) = ip()
	x = ip()
	mx = max(x)
	x = [mx - i for i in x]
	k -= 1
	if k % 2:
		mx = max(x)
		x = [mx - i for i in x]
	print(*x)


def compute_final_array(array, operations_n):
	array = list(array)
	operations_applied = 0
	while operations_applied < 2 and operations_applied < operations_n:
		d = max(array)
		array = [d - x for x in array]
		operations_applied += 1
	if operations_applied == operations_n:
		return array
	operations_remain = operations_n - operations_applied
	if operations_remain % 2 != 0:
		d = max(array)
		array = [d - x for x in array]
	return array

def main():
	t = int(input())
	for i in range(t):
		(n, k) = map(int, input().split())
		array = tuple(map(int, input().split()))
		result = compute_final_array(array, k)
		print(*result)
main()


for i1 in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	d = max(l)
	l_odd = [d - l[i] for i in range(n)]
	d1 = max(l_odd)
	l_even = [d1 - l_odd[i] for i in range(n)]
	if k % 2 == 0:
		for i in l_even:
			print(i, end=' ')
		print()
	else:
		for i in l_odd:
			print(i, end=' ')
		print()


import sys
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]
for _ in range(II()):
	(n, k) = MI()
	aa = LI()
	loop = 1 if k & 1 else 2
	for _ in range(loop):
		d = max(aa)
		for i in range(n):
			aa[i] = d - aa[i]
	print(*aa)


n = int(input())
for i in range(n):
	(l, m) = map(int, input().split())
	k = list(map(int, input().split()))
	d = max(k)
	for j in range(l):
		k[j] = d - k[j]
	if m % 2 == 0:
		p = max(k)
		for q in range(l):
			k[q] = p - k[q]
	print(*k)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	if k % 2 == 0:
		k = 2
	else:
		k = 1
	for i in range(k):
		d = max(arr)
		for j in range(n):
			arr[j] = d - arr[j]
	print(*arr)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	if k > 4:
		k -= 2 * ((k - 5) // 2)
	l = list(map(int, input().split()))
	for i in range(k):
		d = max(l)
		for j in range(n):
			l[j] = d - l[j]
	print(' '.join(map(str, l)))


T_ON = 1
DEBUG_ON = 0
MOD = 998244353

def solve():
	(n, k) = read_ints()
	A = read_ints()

	def run(A):
		x = max(A)
		for (i, a) in enumerate(A):
			A[i] = x - A[i]
	run(A)
	k -= 1
	if k % 2:
		run(A)
	print_nums(A)

def main():
	T = read_int() if T_ON else 1
	for i in range(T):
		solve()

def debug(*xargs):
	if DEBUG_ON:
		print(*xargs)
from collections import *
import math
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def read_int():
	return int(input())

def read_ints():
	return list(map(int, input().split()))

def print_nums(nums):
	print(' '.join(map(str, nums)))

def YES():
	print('YES')

def Yes():
	print('Yes')

def NO():
	print('NO')

def No():
	print('No')

def First():
	print('First')

def Second():
	print('Second')

def fib(n):
	(a, b) = (0, 1)
	for _ in range(n):
		(a, b) = (b, a + b)
	return a

def fib_ns(n):
	assert n >= 1
	f = [0 for _ in range(n + 1)]
	f[0] = 0
	f[1] = 1
	for i in range(2, n + 1):
		f[i] = f[i - 1] + f[i - 2]
	return f

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def xgcd(a, b):
	(x0, x1, y0, y1) = (0, 1, 1, 0)
	while a != 0:
		((q, a), b) = (divmod(b, a), a)
		(y0, y1) = (y1, y0 - q * y1)
		(x0, x1) = (x1, x0 - q * x1)
	return (b, x0, y0)

def lcm(a, b):
	d = gcd(a, b)
	return a * b // d

def modinv(a, m):
	(g, x, _) = xgcd(a, m)
	if g != 1:
		raise Exception('gcd(a, m) != 1')
	return x % m

def mod_add(x, y):
	x += y
	while x >= MOD:
		x -= MOD
	while x < 0:
		x += MOD
	return x

def mod_mul(x, y):
	return x * y % MOD

def mod_pow(x, y):
	if y == 0:
		return 1
	if y % 2:
		return mod_mul(x, mod_pow(x, y - 1))
	p = mod_pow(x, y // 2)
	return mod_mul(p, p)

def mod_inv(y):
	return mod_pow(y, MOD - 2)

def mod_div(x, y):
	return mod_mul(x, mod_inv(y))

def is_prime(n):
	if n == 1:
		return False
	for i in range(2, int(n ** 0.5) + 1):
		if n % i:
			return False
	return True

def gen_primes(n):
	P = [True for _ in range(n + 1)]
	P[0] = P[1] = False
	for i in range(int(n ** 0.5) + 1):
		if P[i]:
			for j in range(2 * i, n + 1, i):
				P[j] = False
	return P
main()


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	d = max(a)
	for i in range(len(a)):
		a[i] = d - a[i]
	if k % 2 == 0:
		d1 = max(a)
		for i in range(len(a)):
			a[i] = d1 - a[i]
		print(*a, sep=' ')
	else:
		print(*a, sep=' ')


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	aa = [0 for i in range(n)]
	aaa = [0 for i in range(n)]
	d = max(a)
	for i in range(n):
		aa[i] = d - a[i]
	d = max(aa)
	for i in range(n):
		aaa[i] = d - aa[i]
	if k % 2 == 0:
		for i in range(n):
			print(aaa[i], end=' ')
		print()
	else:
		for i in range(n):
			print(aa[i], end=' ')
		print()


from sys import stdin
tt = int(stdin.readline())
for loop in range(tt):
	(n, k) = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	k -= 1
	M = max(a)
	for i in range(n):
		a[i] = M - a[i]
	if k % 2 == 0:
		print(*a)
	else:
		M = max(a)
		for i in range(n):
			a[i] = M - a[i]
		print(*a)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	(m1, m2) = (min(a), max(a))
	if k & 1:
		for i in range(n):
			a[i] = m2 - a[i]
	else:
		for i in range(n):
			a[i] = a[i] - m1
	print(*a)


def solve(li):
	Max = max(li)
	new = [Max - value for value in li]
	return new
for i in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	li = [int(x) for x in input().split()]
	li_odd = solve(li)
	li_even = solve(li_odd)
	print(*li_odd) if k % 2 != 0 else print(*li_even)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	x = list(map(int, input().split()))
	if k % 2 == 0:
		m = max(x)
		y = list(map(lambda a: m - a, x))
		p = max(y)
		z = list(map(lambda a: p - a, y))
		z = list(map(str, z))
		print(' '.join(z))
	else:
		m = max(x)
		x = list(map(lambda a: m - a, x))
		x = list(map(str, x))
		print(' '.join(x))


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	(N, K) = map(int, input().split())
	A = list(map(int, input().split()))
	B = []
	C = []
	a = max(A)
	for i in range(N):
		B.append(a - A[i])
	a = max(B)
	for i in range(N):
		C.append(a - B[i])
	if K % 2 == 0:
		print(*C)
	else:
		print(*B)


t = int(input())
while t > 0:
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	a = input().split()
	a = [int(i) for i in a]
	mx = max(a)
	a = [mx - i for i in a]
	if k % 2 != 0:
		for i in a:
			print(i, end=' ')
	else:
		mx = max(a)
		for i in a:
			print(mx - i, end=' ')
	print()
	t -= 1


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	(n, m) = (min(a), max(a))
	b = [m - x for x in a]
	c = [x - n for x in a]
	if k & 1:
		print(*b)
	else:
		print(*c)


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt, pi, cos, sin, ceil, log2
from bisect import bisect_right, bisect_left
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def factorial(n):
	if n == 0:
		return 1
	return n * factorial(n - 1)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)

def sumDigits(no):
	return 0 if no == 0 else int(no % 10) + sumDigits(int(no / 10))
MOD = 1000000007
PMOD = 998244353
N = 10 ** 5
T = 1
T = int(stdin.readline())
for _ in range(T):
	(n, k) = list(map(int, stdin.readline().rstrip().split()))
	a = list(map(int, stdin.readline().rstrip().split()))
	d1 = max(a)
	for i in range(n):
		a[i] = d1 - a[i]
	f1 = a.copy()
	d2 = max(a)
	for i in range(n):
		a[i] = d2 - a[i]
	f2 = a.copy()
	k -= 1
	if k % 2 == 0:
		print(*f1)
	else:
		print(*f2)


def sol(lis, k):
	d = max(lis)
	for i in range(len(lis)):
		lis[i] = d - lis[i]
	k -= 1
	if k % 2 == 0:
		return lis
	d = max(lis)
	for i in range(len(lis)):
		lis[i] = d - lis[i]
	return lis
k = int(input())
for i in range(k):
	(n, m) = list(map(int, input().split(' ')))
	lis = list(map(int, input().split(' ')))
	lis = sol(lis, m)
	for j in lis:
		print(j, end=' ')
	print()


import os
import sys
from io import BytesIO, IOBase
from collections import Counter, defaultdict
from collections import deque
from functools import cmp_to_key
import math

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
MAX = float('inf')
MIN = float('-inf')
MOD = 1000000007

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	s = set()
	for p in range(2, n + 1):
		if prime[p]:
			s.add(p)
	return s

def readTree(n, m):
	adj = [deque([]) for _ in range(n + 1)]
	for _ in range(m):
		(u, v) = ain()
		adj[u].append(v)
		adj[v].append(u)
	return adj

def main():
	for _ in range(iin()):
		(n, k) = ain()
		l = ain()
		maxi = max(l)
		mini = min(l)
		if k % 2 == 0:
			for i in range(n):
				l[i] -= mini
		else:
			for i in range(n):
				l[i] = maxi - l[i]
		print(*l)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if os.getcwd() == 'D:\\code':
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import Counter
import heapq
from collections import Counter
from bisect import bisect_right
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	if k % 2 == 0:
		m = max(arr)
		ans = [0] * n
		for i in range(n):
			ans[i] = m - arr[i]
		m = max(ans)
		ans1 = [0] * n
		for i in range(n):
			ans1[i] = m - ans[i]
		print(*ans1)
	else:
		m = max(arr)
		ans = [0] * n
		for i in range(n):
			ans[i] = m - arr[i]
		print(*ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	c = max(a)
	for i in range(n):
		a[i] = c - a[i]
	k = k - 1
	c = max(a)
	if k % 2 == 1:
		for i in a:
			print(c - i, end=' ')
		print()
	else:
		print(*a)


t = int(input())
for you in range(t):
	l = input().split()
	n = int(l[0])
	k = int(l[1])
	l = input().split()
	li = [int(i) for i in l]
	x = min(li)
	y = max(li)
	if k % 2:
		for i in li:
			print(y - i, end=' ')
		print()
	else:
		for i in li:
			print(i - x, end=' ')
		print()


t = int(input())
for x in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	maxx = arr[0]
	minn = arr[0]
	for x in arr:
		maxx = max(x, maxx)
		minn = min(x, minn)
	if k % 2 == 0:
		for x in arr:
			print(x - minn, end=' ')
	else:
		for x in arr:
			print(maxx - x, end=' ')
	print()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ls = list(map(int, input().split()))
	d = max(ls)
	a = [d - i for i in ls]
	d1 = max(a)
	b = [d1 - j for j in a]
	if k % 2 == 0:
		print(*b)
	else:
		print(*a)


for _ in range(int(input())):
	(l, n) = map(int, input().split())
	a = list(map(int, input().split()))
	m = min(a)
	M = max(a)
	a = [M - i for i in a]
	x = M - m
	if n % 2 == 0:
		print(*[x - i for i in a])
	else:
		print(*a)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split(' '))
	a = list(map(int, input().split()))
	if k % 2 == 0:
		for i in range(2):
			m = max(a)
			for i in range(n):
				a[i] = m - a[i]
		print(*a)
	else:
		m = max(a)
		for i in range(n):
			a[i] = m - a[i]
		print(*a)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	d = max(a)
	r = []
	p = []
	if k % 2 == 1:
		for i in a:
			i = d - i
			r.append(i)
	else:
		for i in a:
			i = d - i
			p.append(i)
		d = max(p)
		for i in p:
			i = d - i
			r.append(i)
	print(*r)


for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = a[:]
	mx = max(a)
	mn = min(a)
	mx1 = mx - mn
	for i in range(n):
		b[i] = mx - a[i]
		a[i] = mx1 - b[i]
	if k % 2 == 0:
		print(*a)
	else:
		print(*b)


import math, sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda : int(input())
li = lambda : list(map(int, input().split()))

def solve():
	(n, k) = li()
	a = li()
	c = []
	d = []
	for i in range(1):
		m = max(a)
		for j in range(n):
			a[j] = m - a[j]
		c = a.copy()
	for i in range(1):
		m = max(a)
		for j in range(n):
			a[j] = m - a[j]
		d = a.copy()
	if k % 2:
		print(*c)
	else:
		print(*d)
for _ in range(I()):
	solve()


t = int(input())
while t:
	line = input().split()
	(n, k) = (int(line[0]), int(line[1]))
	a = input().split()
	a = list(map(int, a))
	m = max(a)
	x = []
	for xx in a:
		x.append(m - xx)
	m = max(x)
	y = []
	for xx in x:
		y.append(m - xx)
	if k % 2 == 0:
		ans = y
	else:
		ans = x
	for xx in ans:
		print(xx, end=' ')
	print()
	t -= 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list((int(i) for i in input().split()))
	mx = max(arr)
	for i in range(n):
		arr[i] = mx - arr[i]
	if k % 2 != 0:
		print(*arr)
	elif k % 2 == 0:
		mx = max(arr)
		for i in range(n):
			arr[i] = mx - arr[i]
		print(*arr)


cases = int(input())
for i in range(cases):
	l1 = input().split(' ')
	l2 = input().split(' ')
	n = int(l1[0])
	k = int(l1[1])
	arr = []
	for a in l2:
		arr.append(int(a))
	if len(arr) == 1:
		print(0)
		continue
	ma = max(arr)
	mi = min(arr)
	d = ma - mi
	if k % 2 == 0:
		for j in range(n):
			if arr[j] == mi:
				arr[j] = str(0)
			elif arr[j] == ma:
				arr[j] = str(ma - mi)
			else:
				c = arr[j] - mi
				arr[j] = str(c)
	elif k % 2 == 1:
		for j in range(n):
			if arr[j] == ma:
				arr[j] = str(0)
			elif arr[j] == mi:
				arr[j] = str(ma - mi)
			else:
				arr[j] = str(ma - arr[j])
	print(' '.join(arr))


for x in range(int(input())):
	(n, k) = list(map(int, input().split()))
	m = list(map(int, input().split()))
	z = max(m)
	k -= 1
	d = [0] * n
	for i in range(n):
		d[i] = z - m[i]
	z = max(d)
	p = [0] * n
	for i in range(n):
		p[i] = z - d[i]
	if k % 2:
		print(*p)
	else:
		print(*d)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	L = list(map(int, input().split()))
	if n == 1:
		print(0)
		continue
	val = max(L)
	for i in range(n):
		L[i] = val - L[i]
	k -= 1
	if k == 0:
		print(*L)
		continue
	if k & 1 == 0:
		print(*L)
	if k & 1 == 1:
		val = max(L)
		for i in range(n):
			L[i] = val - L[i]
		print(*L)


import math
t = int(input())
for q in range(t):
	(n, k) = [int(i) for i in input().split()]
	L = [int(i) for i in input().split()]
	if k > 0 and k % 2 == 1:
		ma = max(L)
		for i in range(n):
			L[i] = ma - L[i]
	elif k > 0 and k % 2 == 0:
		mi = min(L)
		for i in range(n):
			L[i] = L[i] - mi
	for i in L:
		print(i, end=' ')
	print('')


t = int(input())
for i in range(0, t):
	nk = input().split()
	n = int(nk[0])
	k = int(nk[1])
	a = input().split()
	for j in range(0, n):
		a[j] = int(a[j])
	d = max(a)
	a = [d - x for x in a]
	k -= 1
	if k % 2:
		d = max(a)
		a = [d - x for x in a]
		k -= 1
	for x in a:
		print(x, end=' ')
	print()


t = int(input())
ans = []
for _ in range(t):
	[n, k] = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	if n == 1:
		ans.append([0])
	else:
		mx = max(arr)
		mn = min(arr)
		if k % 2:
			for idx in range(n):
				arr[idx] = mx - arr[idx]
		else:
			for idx in range(n):
				arr[idx] = arr[idx] - mn
		ans.append(arr)
for ar in ans:
	for x in ar:
		print(x, end=' ')
	print(end='\n')


import sys
input = sys.stdin.readline
for nt in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	for j in range(2):
		if j % 2:
			maxx = max(a)
			for i in range(n):
				a[i] = maxx - a[i]
			odd = a[:]
		else:
			maxx = max(a)
			for i in range(n):
				a[i] = maxx - a[i]
			even = a[:]
	if not k % 2:
		print(*odd)
	else:
		print(*even)


import math
import sys
import bisect
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	maxi = max(l[:])
	d = maxi - min(l[:])
	for i in range(n):
		l[i] = maxi - l[i]
	k -= 1
	if k % 2 == 0:
		print(*l)
	else:
		for i in range(n):
			l[i] = d - l[i]
		print(*l)


from sys import stdin
for _ in range(int(stdin.readline())):
	(n, k) = list(map(int, stdin.readline().split()))
	a = list(map(int, stdin.readline().split()))
	for _ in range(2 - k % 2):
		d = max(a)
		a = list(map(lambda x: d - x, a))
	print(*a)


import math
t = input()
t = int(t)
while t > 0:
	s = input()
	(n, k) = (int(x) for x in s.split())
	s = input()
	a = [int(x) for x in s.split()]
	mn = min(a)
	mx = max(a)
	if k % 2 == 0:
		for i in range(len(a)):
			a[i] = a[i] - mn
	else:
		for i in range(len(a)):
			a[i] = mx - a[i]
	print(' '.join([str(x) for x in a]))
	t -= 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	num = list(map(int, input().split()))
	val = max(num)
	for i in range(n):
		num[i] = val - num[i]
	k -= 1
	if k % 2 == 0:
		print(' '.join(map(str, num)))
	else:
		val = max(num)
		for i in range(n):
			num[i] = val - num[i]
		print(' '.join(map(str, num)))


from typing import List

def omkar_and_infinity_clock(k: int, nums: List[int]) -> str:
	maximum = max(nums)
	if k % 2 == 1:
		return ' '.join([str(maximum - i) for i in nums])
	else:
		nums = [maximum - i for i in nums]
		maximum = max(nums)
		return ' '.join([str(maximum - i) for i in nums])
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	print(omkar_and_infinity_clock(k, a))


def solve():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	d = max(a)
	for i in range(n):
		a[i] = d - a[i]
	if k % 2 == 0:
		d = max(a)
		for i in range(n):
			a[i] = d - a[i]
	print(' '.join(map(str, a)))
for _ in range(int(input())):
	solve()


T = int(input())
while T:
	T -= 1
	(N, K) = input().split()
	(N, K) = (int(N), int(K))
	A = list(map(int, input().split()))
	minA = 1000000001
	maxA = -1000000001
	for i in range(0, N):
		if maxA < A[i]:
			maxA = A[i]
		if minA > A[i]:
			minA = A[i]
	if K % 2 == 1:
		for i in range(0, N):
			print(maxA - A[i], end=' ')
	else:
		for i in range(0, N):
			print(A[i] - minA, end=' ')
	print('')


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	(M, m) = (a[0], a[0])
	for i in a:
		if i > M:
			M = i
		if i < m:
			m = i
	a1 = list.copy(a)
	for i in range(n):
		a1[i] = M - a1[i]
	a2 = list.copy(a1)
	for i in range(n):
		a2[i] = M - m - a2[i]
	if k % 2:
		for i in a1:
			print(i, end=' ')
	else:
		for i in a2:
			print(i, end=' ')
	print()


import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	d = max(a)
	a0 = [d - a[i] for i in range(n)]
	d = max(a0)
	a1 = [d - a0[i] for i in range(n)]
	if k % 2 == 0:
		print(*a1)
	else:
		print(*a0)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	max_a = max(a)
	max_index = 0
	one = []
	two = []
	for i in a:
		one.append(max_a - i)
	max_index = max(one)
	for i in one:
		two.append(max_index - i)
	if k % 2 == 1:
		print(*one)
	else:
		print(*two)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	if k > 4:
		k -= 2 * ((k - 5) // 2)
	for i in range(k):
		d = max(l)
		for j in range(n):
			l[j] = d - l[j]
	for i in l:
		print(i, end=' ')
	print()
pass


T = int(input())
while T > 0:
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	(ma, mi) = (float('-inf'), float('inf'))
	for i in range(n):
		ma = max(ma, arr[i])
		mi = min(mi, arr[i])
	temp_max = 0
	for i in range(n):
		arr[i] = ma - arr[i]
		temp_max = max(temp_max, arr[i])
	if k % 2 == 1:
		print(*arr)
	else:
		for i in range(n):
			arr[i] = temp_max - arr[i]
		print(*arr)
	T -= 1


def get_result(arr, k):
	for i in range(0, 1 if k % 2 != 0 else 2):
		max_val = max(arr)
		for j in range(len(arr)):
			arr[j] = max_val - arr[j]
	return arr
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	print(' '.join(map(str, get_result(arr, k))))


t = int(input())
for t in range(t):
	(n, k) = [int(x) for x in input().split(' ')]
	a = [int(x) for x in input().split(' ')]
	m = min(a)
	M = max(a)
	if k == 0:
		b = [x for x in a]
	elif k % 2 == 1:
		b = [M - x for x in a]
	else:
		b = [x - m for x in a]
	print(*b)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ar = list(map(int, input().split()))
	min1 = min(ar)
	max1 = max(ar)
	for i in range(n):
		if k % 2 == 0:
			ar[i] += -min1
		else:
			ar[i] = max1 + -ar[i]
	print(*ar)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	maxio = max(a)
	minio = min(a)
	anso = list((maxio - int(num) for num in a))
	if k % 2 == 1:
		print(*anso)
	else:
		maxie = maxio - minio
		anse = list((maxie - int(num) for num in anso))
		print(*anse)


t = int(input())
for _ in range(t):
	(n, k) = input().split()
	A = list(map(int, input().split()))
	n = int(n)
	k = int(k)
	d = max(A)
	ans = []
	ans.append([d - A[i] for i in range(n)])
	d = max(ans[0])
	X = ans[0]
	ans.append([d - X[i] for i in range(n)])
	if k % 2 == 0:
		print(' '.join((str(c) for c in ans[1])))
	else:
		print(' '.join((str(c) for c in ans[0])))


for _ in range(int(input())):
	(n, k) = [int(_) for _ in input().split()]
	A = [int(_) for _ in input().split()]
	m = max(A)
	B = [0 for _ in range(n)]
	for _ in range(n):
		A[_] = m - A[_]
	if k == 1:
		print(*A)
	else:
		m = max(A)
		for _ in range(n):
			B[_] = m - A[_]
		if k % 2 == 1:
			print(*A)
		else:
			print(*B)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	v = list(map(int, input().split()))
	k = k % 2
	a = max(v)
	v1 = []
	for i in v:
		v1.append(a - i)
	v2 = []
	b = max(v1)
	for i in v1:
		v2.append(b - i)
	if k == 1:
		print(*v1)
	else:
		print(*v2)


def subtract(array, n, k):
	arr_max = max(array)
	for i in range(n):
		array[i] = arr_max - array[i]
	if (k - 1) % 2 == 0:
		return array
	else:
		arr_max = max(array)
		for i in range(n):
			array[i] = arr_max - array[i]
		return array
test_case = int(input())
for _ in range(test_case):
	nk = input().split()
	n = int(nk[0])
	k = int(nk[1])
	array = list(map(int, input().split()))
	ans = subtract(array, n, k)
	for i in ans:
		print(i, end=' ')
	print('')


from functools import lru_cache
from sys import stdin, stdout
import sys
from math import *
input = stdin.readline
for __ in range(int(input())):
	(n, k) = map(int, input().split())
	ar = list(map(int, input().split()))
	a = []
	m = max(ar)
	for i in range(n):
		a.append(m - ar[i])
	m = max(a)
	b = []
	for i in range(n):
		b.append(m - a[i])
	if k % 2 == 1:
		print(*a)
	else:
		print(*b)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	lst = list(map(int, input().split()))
	(d, d1) = (max(lst), min(lst))
	for i in range(n):
		lst[i] = d - lst[i]
	if k == 1:
		for i in lst:
			print(i, end=' ')
		print()
	else:
		k -= 1
		lst1 = lst.copy()
		d = d - d1
		for i in range(n):
			lst[i] = d - lst[i]
		if k % 2 == 0:
			for i in lst1:
				print(i, end=' ')
			print()
		else:
			for i in lst:
				print(i, end=' ')
			print()


def saurabh(k, n, array):
	for i in range(k):
		d = max(array)
		for j in range(n):
			array[j] = d - array[j]
	print(*array)
for _ in range(int(input())):
	(n, k) = input().split()
	k = int(k)
	n = int(n)
	array = [int(i) for i in input().split()]
	if k % 2 == 0:
		k = 2
	else:
		k = 1
	saurabh(k, n, array)


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	if n == 1:
		print(0)
	else:
		maxa = max(a)
		for i in range(n):
			a[i] = maxa - a[i]
		maxa = max(a)
		if k & 1:
			print(*a)
		else:
			for i in range(n):
				a[i] = maxa - a[i]
			print(*a)


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import defaultdict as dd, deque as dq
import math, string

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7

def solve():
	(N, K) = getInts()
	A = getInts()
	m = max(A)
	A = [m - A[j] for j in range(N)]
	if K % 2 == 1:
		print(*A)
		return
	m = max(A)
	A = [m - A[j] for j in range(N)]
	print(*A)
	return
for _ in range(getInt()):
	solve()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	if k == 1:
		k = 1
	elif k % 2:
		k = 3
	else:
		k = 2
	for __ in range(k):
		m = max(A)
		for i in range(n):
			A[i] = m - A[i]
	print(*A)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	m = max(arr)
	cnt = 0
	if k & 1:
		arr = list(map(lambda x: m - x, arr))
	else:
		while cnt < 2:
			m = max(arr)
			arr = list(map(lambda x: m - x, arr))
			cnt += 1
	print(*arr)


t = int(input())
for w in range(0, t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	d = max(arr)
	odd = []
	even = []
	for i in range(0, n):
		e = d - arr[i]
		odd.append(e)
	m = max(odd)
	for j in range(0, n):
		f = m - odd[j]
		even.append(f)
	odd2 = ' '.join(map(str, odd))
	even2 = ' '.join(map(str, even))
	if k % 2 == 0:
		print(even2)
	elif k % 2 != 0:
		print(odd2)


import sys
t = int(input())
while t:
	t -= 1
	(n, o) = map(int, input().split())
	a = list(map(int, input().split()))
	ae = []
	ao = []
	s = max(a)
	for i in range(n):
		k = s - a[i]
		ao.append(k)
	s2 = max(ao)
	for i in range(n):
		k = s2 - ao[i]
		ae.append(k)
	if o % 2 == 0:
		print(*ae)
	else:
		print(*ao)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	w = max(a)
	x = min(a)
	if k % 2 == 1:
		for i in range(n):
			a[i] = w - a[i]
	else:
		for i in range(n):
			a[i] = a[i] - x
	print(*a)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	l1 = []
	if k % 2 == 0:
		for j in range(2):
			d = max(l)
			for i in range(n):
				l[i] = d - l[i]
		print(*l)
	else:
		d = max(l)
		for i in range(n):
			x = d - l[i]
			l1.append(x)
		print(*l1)


t = int(input())
while t:
	t -= 1
	(n, d) = map(int, input().split())
	l = list(map(int, input().split()))
	m = max(l)
	k = []
	for i in range(len(l)):
		k.append(m - l[i])
	k1 = []
	m = max(k)
	for i in range(len(l)):
		k1.append(m - k[i])
	if d % 2 == 1:
		for i in k:
			print(i, end=' ')
		print('\n')
	else:
		for i in k1:
			print(i, end=' ')
		print('\n')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	m = max(arr)
	for i in range(n):
		arr[i] = m - arr[i]
	k -= 1
	if k % 2:
		m = max(arr)
		for i in range(n):
			arr[i] = m - arr[i]
	print(*arr)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	ar = [int(i) for i in input().split()]
	m = max(ar)
	ar1 = [m - i for i in ar]
	m1 = max(ar1)
	ar2 = [m1 - i for i in ar1]
	if k % 2 == 0:
		print(' '.join((str(i) for i in ar2)))
	else:
		print(' '.join((str(i) for i in ar1)))


def myFun(arr):
	d = max(arr)
	for i in range(len(arr)):
		arr[i] = d - arr[i]
	return arr
t = int(input())
for p in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if n == 1:
		print(0)
	elif k == 1:
		print(*myFun(a))
	elif k == 2:
		print(*myFun(myFun(a)))
	else:
		count = 0
		for i in a:
			if i < 0:
				a = myFun(a)
				count += 1
				break
		if 0 not in a:
			a = myFun(a)
			count += 1
		if (k - count) % 2 == 0:
			print(*a)
		else:
			print(*myFun(a))


def tc():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	m = max(a)
	if len(set(a)) == 1:
		print(' '.join(['0'] * n))
		return
	a = [m - x for x in a]
	m = max(a)
	if k % 2 == 0:
		a = [m - x for x in a]
	print(' '.join(map(str, a)))
T = int(input())
for _ in range(T):
	tc()


def solve(arr):
	MAX = max(arr)
	return [MAX - x for x in arr]
n = int(input())
for _ in range(n):
	(_, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	if len(arr) == 1:
		print(0)
	else:
		arr = solve(arr)
		if k % 2 == 1:
			print(*arr)
		else:
			arr = solve(arr)
			print(*arr)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	ma = max(A)
	mi = min(A)
	if k % 2 == 0:
		for i in range(n):
			print(A[i] - mi, end=' ')
	else:
		for i in range(n):
			print(ma - A[i], end=' ')
	print()


testCases = int(input())
case = []
lst = []
for i in range(testCases):
	case.append(list(map(int, input().split(' '))))
	lst.append(list(map(int, input().split(' '))))

def fun(i):
	m = max(i)
	i = [(l - m) * -1 for l in i]
	return i
for (x, i) in zip(case, lst):
	if len(i) == 1:
		print(0)
	else:
		if x[1] % 2 == 0:
			i = fun(i)
		i = fun(i)
		print(' '.join([str(k) for k in i]))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if n == 1:
		print(0)
	else:
		r = max(a)
		a2 = []
		for i in a:
			a2.append(r - i)
		a3 = []
		q = max(a2)
		for i in a2:
			a3.append(q - i)
		ans = ''
		if k % 2 == 1:
			for i in a2:
				ans += str(i)
				ans += ' '
			print(ans)
		elif k % 2 == 0:
			for i in a3:
				ans += str(i)
				ans += ' '
			print(ans)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	k %= 2
	k += 2
	while k > 0:
		d = max(a)
		for i in range(n):
			a[i] = d - a[i]
		k -= 1
	for x in a:
		print(x, end=' ')
	print()


def func(ai, tt=True):
	if tt == None:
		return ai
	iter = 1 if tt else 2
	while iter:
		m = max(ai)
		for ii in range(n):
			ai[ii] = m - ai[ii]
		iter -= 1
	return ai
for x in range(int(input())):
	(n, k) = map(int, input().split())
	ai = list(map(int, input().split()))
	if len(set(ai)) == 1:
		print(*[0 for i in range(n)], sep=' ')
		continue
	else:
		tt = bool(k % 2) if k > 0 else None
		func(ai, tt)
	print(*ai)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	mx = max(a)
	s1 = []
	for i in a:
		s1.append(mx - i)
	s2 = []
	mx = max(s1)
	for i in s1:
		s2.append(mx - i)
	if k % 2 == 0:
		print(*s2)
	else:
		print(*s1)


T = int(input())

def myprint(a):
	for item in a:
		print(item, end=' ')

def myprint_odd(a, m):
	for item in a:
		print(m - item, end=' ')

def myprint_even(a, m):
	for item in a:
		print(item - m, end=' ')
for _ in range(T):
	(length, k) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	if k == 0:
		myprint(arr)
	elif k % 2 == 1:
		myprint_odd(arr, max(arr))
	else:
		myprint_even(arr, min(arr))
	print()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	if k % 2 == 1:
		m = max(l)
		print(*[m - i for i in l])
	else:
		m = min(l)
		print(*[i - m for i in l])


I = lambda : map(int, input().split())
(t,) = I()
for _ in [0] * t:
	(n, k) = I()
	(*s,) = I()
	for _ in [0] * (2 - k % 2):
		f = max(s)
		s = [f - i for i in s]
	print(*s)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	if k % 2 != 0:
		ma = max(l)
		for i in range(n):
			l[i] = ma - l[i]
	else:
		for i in range(2):
			ma = max(l)
			for j in range(n):
				l[j] = ma - l[j]
	print(*l)


for t in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	ma = max(a)
	a = list(map(lambda x: ma - x, a))
	if k == 1:
		print(' '.join(list(map(str, a))))
	else:
		ma = max(a)
		a = list(map(lambda x: ma - x, a))
		if k == 2:
			print(' '.join(list(map(str, a))))
		else:
			maxi = max(a)
			k = k - 2
			for i in range(n):
				if k % 2 == 1:
					a[i] = maxi - a[i]
			print(' '.join(list(map(str, a))))


import sys
read = sys.stdin.readline
write = sys.stdout.write
T = int(read())
for t in range(T):
	(n, k) = map(int, read().split())
	a = list(map(int, read().split()))
	max_val = max(a)
	odd = list(map(lambda x: max_val - x, a))
	odd_max = max(odd)
	even = list(map(lambda x: odd_max - x, odd))
	if k % 2:
		for i in odd:
			write('{} '.format(i))
		write('\n')
	else:
		for i in even:
			write('{} '.format(i))
		write('\n')


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	li = list(map(int, input().split()))
	val = max(li)
	odd_arr = []
	for i in range(n):
		odd_arr.append(val - li[i])
	even_arr = []
	val = max(odd_arr)
	for i in range(n):
		even_arr.append(val - odd_arr[i])
	if k % 2 == 0:
		for i in range(n):
			print(even_arr[i], end=' ')
		print()
	else:
		for i in range(n):
			print(odd_arr[i], end=' ')
		print()


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	k = k % 2
	l = list(map(int, input().split()))
	max0 = max(l)
	min0 = min(l)
	for j in range(n):
		l[j] = max0 - l[j]
	if k == 0:
		max0 -= min0
		for j in range(n):
			l[j] = max0 - l[j]
	for p in range(n):
		print(l[p], end=' ')


t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	maxi = max(a)
	mini = min(a)
	arr = a.copy()
	for i in range(n):
		arr[i] = maxi - a[i]
	arr2 = arr.copy()
	maxi = max(arr)
	for i in range(n):
		arr2[i] = maxi - arr[i]
	if k % 2 == 0:
		print(*arr2)
	elif k % 2 == 1:
		print(*arr)
	t -= 1


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	c = []
	d = max(a)
	for i in range(n):
		c.append(d - a[i])
	d = max(c)
	e = []
	for i in range(n):
		e.append(d - c[i])
	if k == 0:
		print(*a)
	elif k % 2 == 0:
		print(*e)
	else:
		print(*c)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	ar = list(map(int, input().split()))
	m = max(ar)
	new = []
	for i in range(n):
		new.append(m - ar[i])
	if k % 2 == 0:
		mx = max(new)
		for j in range(n):
			new[j] = mx - new[j]
	print(*new)


def final(arr, x):
	d = max(arr)
	arr = list(map(lambda x: d - x, arr))
	if x % 2:
		return arr
	else:
		d = max(arr)
		return list(map(lambda x: d - x, arr))
t = int(input())
for _ in range(t):
	nk = list(map(int, input().strip().split()))
	n = nk[0]
	k = nk[1]
	result = final(list(map(int, input().strip().split())), k)
	print(*result)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	d = max(a)
	for (m, j) in enumerate(a):
		a[m] = d - j
	b = a.copy()
	d = max(b)
	for (m, j) in enumerate(b):
		b[m] = d - j
	if k % 2 == 0:
		print(' '.join(map(str, b)))
	else:
		print(' '.join(map(str, a)))


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	if m % 2 == 0:
		d = min(a)
		for i in range(n):
			a[i] = a[i] - d
	else:
		d = max(a)
		for i in range(n):
			a[i] = d - a[i]
	print(*a, sep=' ')


def change(l):
	d = max(l)
	for i in range(len(l)):
		l[i] = d - l[i]
	return l

def solve():
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	if k % 2 == 1:
		l = change(l)
	else:
		l = change(l)
		l = change(l)
	print(*l)
t = int(input())
for i in range(t):
	solve()


tc = int(input())
while tc:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	mx = max(a)
	for i in range(n):
		a[i] = mx - a[i]
	mx = max(a)
	b = []
	for i in range(n):
		b.append(mx - a[i])
	if k % 2 == 1:
		print(*a, end=' ')
		print()
	else:
		print(*b, end=' ')
		print()
	tc -= 1


def solve(n, k, a):
	if k % 2 == 1:
		k = 1
	else:
		k = 2
	for i in range(k):
		d = max(a)
		for j in range(len(a)):
			a[j] = d - a[j]
	return a
t = int(input())
for tt in range(1, t + 1):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	print(*solve(n, k, a))


from collections import defaultdict as dd
import math
import sys
input = sys.stdin.readline

def nn():
	return int(input())

def li():
	return list(input())

def mi():
	return map(int, input().split())

def lm():
	return list(map(int, input().split()))

def solve():
	(n, k) = mi()
	nums = lm()
	d = max(nums)
	m = min(nums)
	ans = []
	if k % 2 == 1:
		for num in nums:
			ans.append(d - num)
	else:
		for num in nums:
			ans.append(d - m - (d - num))
	print(*ans)
q = nn()
for _ in range(q):
	solve()


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	ar = list(map(int, input().split()))
	max_n_1 = max(ar)
	ar_1 = list(map(lambda x: max_n_1 - x, ar))
	max_n_2 = max(ar_1)
	ar_2 = list(map(lambda x: max_n_2 - x, ar_1))
	if k % 2 == 1:
		print(*ar_1)
	else:
		print(*ar_2)


for i in range(int(input())):
	(n, k) = [int(num) for num in input().split()]
	x = list(map(int, input().split()))
	lst = list()
	lst1 = list()
	c = max(x)
	for i in x:
		c1 = c - i
		lst.append(c1)
	c2 = max(lst)
	for i in lst:
		c3 = c2 - i
		lst1.append(c3)
	if k == 0:
		print(*x, sep=' ')
	if k % 2 != 0 and k != 0:
		print(*lst, sep=' ')
	elif k % 2 == 0 and k != 0:
		print(*lst1, sep=' ')


import sys

def input():
	return sys.stdin.readline().rstrip()

def input_split():
	return [int(i) for i in input().split()]
testCases = int(input())
answers = []
for _ in range(testCases):
	(n, k) = input_split()
	arr = input_split()
	maxi = max(arr)
	mini = min(arr)
	if k % 2 == 0:
		barr = [a - mini for a in arr]
	else:
		barr = [maxi - a for a in arr]
	answers.append(barr)
for ans in answers:
	print(*ans, sep=' ')


import sys
input = sys.stdin.readline
t = int(input())
while t:
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	mx = max(l)
	for i in range(n):
		l[i] = mx - l[i]
	k -= 1
	if k % 2 == 0:
		print(*l)
	else:
		mx = max(l)
		for i in range(n):
			l[i] = mx - l[i]
		print(*l)
	t -= 1


import sys, math
try:
	(sys.stdin, sys.stdout) = (open('input.txt', 'r'), open('out.txt', 'w'))
except:
	pass
from time import clock
a = clock()
from sys import stdin, stdout
mod = int(1000000000.0 + 7)
from statistics import mode
from collections import *
from math import ceil, floor, inf, factorial, gcd, log2, sqrt, log
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()

def lcm(a, b):
	return a * b // gcd(a, b)

def setbits(n):
	return bin(n).count('1')

def resetbits(n):
	return bin(n).count('0')

def modinv(n, p):
	return pow(n, p - 2, p)

def ncr(n, r):
	(num, den) = (1, 1)
	r = min(n, n - r)
	for i in range(r):
		num *= n - i
		den *= i + 1
	return num // den

def ncr_p(n, r, p):
	(num, den) = (1, 1)
	r = min(r, n - r)
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * modinv(den, p) % p

def isPrime(num):
	if num <= 1:
		return False
	if num == 2 or n == 3:
		return True
	if num % 2 == 0 or num % 3 == 0:
		return False
	m = int(num ** 0.5) + 1
	for i in range(5, m, 6):
		if num % i == 0 or num % (i + 2) == 0:
			return False
	return True

def bin_search(arr, low, high, val):
	while low <= high:
		mid = low + (high - low) // 2
		if arr[mid] == val:
			return mid
		elif arr[mid] < val:
			low = mid + 1
		else:
			high = mid - 1
	return -1

def sumofdigit(num):
	count = 0
	while num:
		count += num % 10
		num //= 10
	return count

def inputmatrix():
	(r, c) = iia()
	mat = [0] * r
	for i in range(r):
		mat[i] = iia()
	return (r, c, mat)

def prefix_sum(n, arr):
	for i in range(1, n):
		arr[i] += arr[i - 1]
	return arr

def binomial(n, k):
	if 0 <= k <= n:
		ntok = 1
		ktok = 1
		for t in range(1, min(k, n - k) + 1):
			ntok *= n
			ktok *= t
			n -= 1
		return ntok // ktok
	else:
		return 0

def divisors(n):
	res = []
	for i in range(1, ceil(sqrt(n)) + 1):
		if n % i == 0:
			if i == n // i:
				res.append(i)
			else:
				res.append(i)
				res.append(n // i)
	return res
for _ in range(ii1()):
	(n, k) = iia()
	arr = iia()
	a = max(arr)
	for i in range(n):
		arr[i] = a - arr[i]
	if k == 1:
		print(*arr)
	else:
		k -= 1
		if k % 2 == 1:
			a = max(arr)
			for i in range(n):
				arr[i] = a - arr[i]
			print(*arr)
		else:
			print(*arr)


t = int(input())
for l in range(0, t):
	(n, k) = [int(a) for a in input().split()]
	a = [int(a) for a in input().split()]
	if not k % 2:
		t = 2
	else:
		t = 1
	for j in range(0, t):
		d = max(a)
		for i in range(0, n):
			a[i] = d - a[i]
	for j in range(0, len(a)):
		print(a[j], end=' ')
	print()


def main():
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		s = list(map(int, input().split()))
		if n == 1:
			print(0)
		else:
			minn = 1000000001
			maxn = -1000000001
			for i in s:
				if i < minn:
					minn = i
				if i > maxn:
					maxn = i
			if k % 2 == 1:
				for i in s:
					print(maxn - i, end=' ')
			else:
				for i in s:
					print(i - minn, end=' ')
		print()
main()


T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	min_idx = 0
	max_idx = 0
	for i in range(len(l)):
		if l[min_idx] > l[i]:
			min_idx = i
		if l[max_idx] < l[i]:
			max_idx = i
	for i in range(len(l)):
		if k % 2 == 1:
			print(l[max_idx] - l[i], end=' ')
		else:
			print(l[max_idx] - l[min_idx] - (l[max_idx] - l[i]), end=' ')
	print()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	m = [min(a), max(a)][k % 2]
	print(*[abs(i - m) for i in a])


t = int(input())
for i in range(t):
	(n, p) = map(int, input().split())
	lst = list(map(int, input().split()))
	d = max(lst)
	for j in range(n):
		a = d - lst[j]
		lst[j] = a
	if p % 2 == 0:
		d = max(lst)
		for k in range(n):
			a = d - lst[k]
			lst[k] = a
		for i in range(len(lst)):
			print(lst[i], end='')
			if i < len(lst) - 1:
				print(' ', end='')
		print('')
	else:
		for i in range(len(lst)):
			print(lst[i], end='')
			if i < len(lst) - 1:
				print(' ', end='')
		print('')


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
from decimal import Decimal
mod = pow(10, 9) + 7

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(int(data())):
	(n, k) = sp()
	arr = l()
	mini = min(arr)
	maxi = max(arr)
	second = [maxi - i for i in arr]
	maxi = max(second)
	third = [maxi - i for i in second]
	if k & 1:
		outa(*second)
	else:
		outa(*third)
	continue


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	mx = max(arr)
	if k % 2 == 0:
		for i in range(2):
			for j in range(len(arr)):
				arr[j] = mx - arr[j]
			mx = max(arr)
	else:
		for i in range(len(arr)):
			arr[i] = mx - arr[i]
	print(*arr)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
inp = lambda : int(input())
strng = lambda : input().strip()
jn = lambda x, l: x.join(map(str, l))
strl = lambda : list(input().strip())
mul = lambda : map(int, input().strip().split())
mulf = lambda : map(float, input().strip().split())
seq = lambda : list(map(int, input().strip().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
stdarr = lambda : map(int, stdstr().split())
mod = 1000000007
for _ in range(stdint()):
	(n, k) = stdarr()
	arr = list(stdarr())
	m = max(arr)
	res = []
	if k % 2 == 0:
		mi = min(arr)
		for i in range(n):
			res.append(arr[i] - mi)
	else:
		ma = max(arr)
		for i in range(n):
			res.append(ma - arr[i])
	print(*res)


t = int(input())
for ex in range(t):
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	m = max(a)
	mi = m - min(a)
	a1 = [0 for i in range(n)]
	for i in range(n):
		a[i] = m - a[i]
		a1[i] = mi - a[i]
	k -= 1
	if k % 2 == 1:
		print(*a1)
	else:
		print(*a)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	d = max(a)
	odd = [d - e for e in a]
	d = max(odd)
	even = [d - e for e in odd]
	if k % 2 == 0:
		print(*even)
	else:
		print(*odd)


def ans(arr):
	return ' '.join([str(x) for x in arr])
for i in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	d = max(arr)
	odd = [d - arr[i] for i in range(n)]
	dd = max(odd)
	eve = [dd - odd[i] for i in range(n)]
	if k & 1:
		print(ans(odd))
	else:
		print(ans(eve))


t = int(input())
for __ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	max_ = max(arr)
	min_ = min(arr)
	if k % 2:
		print(' '.join(map(str, [max_ - a for a in arr])))
	else:
		print(' '.join(map(str, [a - min_ for a in arr])))


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().rstrip().split()))
	a = list(map(int, input().rstrip().split()))
	if n == 1:
		print(0)
	else:
		mx = max(a)
		mn = min(a)
		a_new0 = [0] * n
		a_new1 = [0] * n
		for i in range(n):
			a_new0[i] = mx - a[i]
		mx_new = mx - mn
		mn_new = 0
		for i in range(n):
			a_new1[i] = mx_new - a_new0[i]
		if k % 2 != 0:
			for x in a_new0:
				print(x, end=' ')
		else:
			for x in a_new1:
				print(x, end=' ')
		print()


from sys import stdin, stdout

def fn(a):
	mx = max(a)
	return [mx - v for v in a]
for _ in range(int(stdin.readline())):
	(n, k) = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	op1 = fn(a)
	op2 = fn(op1)
	if k & 1:
		print(*op1)
	else:
		print(*op2)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	maxa = max(a)
	b = [maxa - ai for ai in a]
	maxb = max(b)
	c = [maxb - bi for bi in b]
	if k & 1:
		print(*b)
	else:
		print(*c)


t = int(input())
for i in range(t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	A = input().split()
	a = list(map(int, A))
	b = []
	c = []
	d = max(a)
	for i in range(n):
		e = d - a[i]
		b.append(e)
	f = max(b)
	for i in range(n):
		g = f - b[i]
		c.append(g)
	if k % 2 != 0:
		print(*b, sep=' ')
	else:
		print(*c, sep=' ')


T = int(input())
for _ in range(T):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	ans = {}
	for j in range(2):
		d = max(a)
		for i in range(n):
			a[i] = d - a[i]
		ans[j] = ' '.join(map(str, a))
	print(ans[(k - 1) % 2])


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	mex = max(arr)
	mn = min(arr)
	if k & 1:
		for i in range(n):
			arr[i] = mex - arr[i]
	else:
		for i in range(n):
			arr[i] = arr[i] - mn
	print(*arr)


t = int(input())
for r in range(t):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	m = max(a)
	if k == 0:
		print(*a)
	else:
		for i in range(n):
			a[i] = m - a[i]
		if k % 2 == 1:
			print(*a)
		else:
			m = max(a)
			for i in range(n):
				a[i] = m - a[i]
			print(*a)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	if k % 2 == 0:
		m = 2
	else:
		m = 1
	for i in range(m):
		l = max(a)
		for j in range(len(a)):
			a[j] = l - a[j]
	for i in range(len(a) - 1):
		print(a[i], end=' ')
	print(a[-1])


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	m = max(a)
	a = [m - i for i in a]
	if k % 2 == 1:
		print(*a)
	else:
		m = max(a)
		a = [m - i for i in a]
		print(*a)


for _ in range(int(input())):
	(n, k) = [int(c) for c in input().split()]
	arr = [int(c) for c in input().split()]
	if k == 1:
		d = max(arr)
		a = [d - i for i in arr]
		print(*a)
	elif k >= 2:
		d = max(arr)
		a = [d - i for i in arr]
		if k & 1:
			print(*a)
		else:
			d = max(a)
			a = [d - i for i in a]
			print(*a)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().strip().split()))[:n]
	d = max(a)
	for i in range(n):
		a[i] = d - a[i]
	d = max(a)
	if k % 2 == 0:
		for i in range(n):
			a[i] = d - a[i]
		print(*a, sep=' ')
	else:
		print(*a, sep=' ')


t = int(input())
for i in range(0, t):
	(n, k) = map(int, input().split())
	ls = list(map(int, input().rstrip().split()))
	if k % 2 == 1:
		maxx = ls[0]
		for l in range(0, n):
			if ls[l] > maxx:
				maxx = ls[l]
		for l in range(0, n):
			ls[l] = maxx - ls[l]
	else:
		j = 0
		while j <= 1:
			maxx = ls[0]
			for l in range(0, n):
				if ls[l] > maxx:
					maxx = ls[l]
			for l in range(0, n):
				ls[l] = maxx - ls[l]
			j = j + 1
	for j in ls:
		print(j, end=' ')
	print(' ')


T = int(input())
for t in range(T):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	s = set(a)
	r = []
	br = 0
	while k > 0:
		d = max(a)
		a = [d - i for i in a]
		k -= 1
		s = set(a)
		if s == {0}:
			break
		if a in r:
			br = 1
			break
		r.append(a)
	if br == 1:
		if k % 2 == 1:
			for x in r[1]:
				print(x, end=' ')
		else:
			for x in r[0]:
				print(x, end=' ')
		print('')
		r.clear()
		a.clear()
		continue
	for x in a:
		print(x, end=' ')
	print('')
	a.clear()


import sys
import string
import math
from collections import defaultdict
from functools import lru_cache
from collections import Counter
from fractions import Fraction

def mi(s):
	return map(int, s.strip().split())

def lmi(s):
	return list(mi(s))

def tmi(s):
	return tuple(mi(s))

def mf(f, s):
	return map(f, s)

def lmf(f, s):
	return list(mf(f, s))

def js(lst):
	return ' '.join((str(d) for d in lst))

def jsns(lst):
	return ''.join((str(d) for d in lst))

def line():
	return sys.stdin.readline().strip()

def linesp():
	return line().split()

def iline():
	return int(line())

def mat(n):
	matr = []
	for _ in range(n):
		matr.append(linesp())
	return matr

def matns(n):
	mat = []
	for _ in range(n):
		mat.append([c for c in line()])
	return mat

def mati(n):
	mat = []
	for _ in range(n):
		mat.append(lmi(line()))
	return mat

def pmat(mat):
	for row in mat:
		print(js(row))

def solve(k, arr):
	arr = list(enumerate(arr))
	arr.sort(key=lambda x: x[1])
	first = []
	for (e, n) in arr:
		first.append((e, arr[-1][1] - n))
	second = []
	for (e, n) in first:
		second.append((e, first[0][1] - n))
	if k % 2 == 0:
		ans = second
	else:
		ans = first
	ans.sort(key=lambda x: x[0])
	ans = [n[1] for n in ans]
	print(js(ans))

def main():
	t = iline()
	for _ in range(t):
		(_, k) = mi(line())
		solve(k, lmi(line()))
main()


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def main():
	t = I()
	rr = []
	for _ in range(t):
		(n, k) = LI()
		a = LI()
		m = max(a)
		b = [m - a[i] for i in range(n)]
		m = max(b)
		if k % 2 == 0:
			b = [m - b[i] for i in range(n)]
		rr.append(JA(b, ' '))
	return JA(rr, '\n')
print(main())


t = int(input())
for case in range(t):
	(n, k) = [int(s) for s in input().split(' ')]
	a = [int(s) for s in input().split(' ')]
	for i in range(2 - k % 2):
		d = max(a)
		a = [d - b for b in a]
	print(' '.join([str(char) for char in a]))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	minn = min(a)
	maxx = max(a)
	temp1 = []
	for i in a:
		temp1.append(maxx - i)
	maxx = max(temp1)
	temp2 = []
	for j in temp1:
		temp2.append(maxx - j)
	if k % 2 == 1:
		print(' '.join(map(str, temp1)))
	else:
		print(' '.join(map(str, temp2)))


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = max(a)
	a = [b - x for x in a]
	if k % 2 == 0:
		b = max(a)
		a = [b - x for x in a]
	print(*a)


for t in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [0] * n
	base = max(a)
	for i in range(n):
		a[i] = base - a[i]
	base = max(a)
	for i in range(n):
		b[i] = base - a[i]
	if k % 2 == 1:
		print(' '.join((str(i) for i in a)))
	else:
		print(' '.join((str(i) for i in b)))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	lis = list(map(int, input().split()))
	d = max(lis)
	tmp1 = [d - x for x in lis]
	d = max(tmp1)
	tmp2 = [d - x for x in tmp1]
	if k & 1:
		print(*tmp1)
	else:
		print(*tmp2)


t = int(input())

def operation(arr):
	max_value = max(arr)
	for i in range(len(arr)):
		arr[i] = max_value - arr[i]
for ti in range(t):
	(n, k) = [int(i) for i in input().split()]
	arr = [int(num) for num in input().split()]
	while k:
		operation(arr)
		if 0 in arr:
			if k > 3:
				k = k % 2 + 2
		k -= 1
	for v in arr:
		print(v, end=' ')
	print()


t = int(input())
for _ in range(t):
	(n, k) = (int(i) for i in input().split())
	a = [int(i) for i in input().split()]
	M = max(a)
	m = min(a)
	ans = []
	if k % 2 == 1:
		ans = [M - i for i in a]
		print(*ans)
	else:
		ans = [i - m for i in a]
		print(*ans)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	f = max(a)
	odd = []
	even = []
	for i in range(n):
		odd.append(f - a[i])
	f = max(odd)
	for i in range(n):
		even.append(f - odd[i])
	if k % 2 != 0:
		print(*odd)
	else:
		print(*even)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if k % 2 == 0:
		m = min(a)
		for j in range(n):
			a[j] = a[j] - m
		print(*a, sep=' ')
	else:
		m = max(a)
		for j in range(n):
			a[j] = m - a[j]
		print(*a, sep=' ')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	k -= 1
	mx = max(a)
	for i in range(n):
		a[i] = mx - a[i]
	mx = max(a)
	if k & 1:
		for i in range(n):
			a[i] = mx - a[i]
	print(*a)


import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
import itertools

def Int():
	return int(sys.stdin.readline())

def Mint():
	return map(int, sys.stdin.readline().split())

def Lstr():
	return list(sys.stdin.readline().strip())

def Str():
	return sys.stdin.readline().strip()

def Mstr():
	return map(str, sys.stdin.readline().strip().split())

def List():
	return list(map(int, sys.stdin.readline().split()))

def Hash():
	return dict()

def Mod():
	return 1000000007

def Ncr(n, r, p):
	return fact[n] * (ifact[r] * ifact[n - r] % p) % p

def Most_frequent(list):
	return max(set(list), key=list.count)

def Mat2x2(n):
	return [List() for _ in range(n)]

def Lcm(x, y):
	return x * y // gcd(x, y)

def dtob(n):
	return bin(n).replace('0b', '')

def btod(n):
	return int(n, 2)

def common(l1, l2):
	return set(l1).intersection(l2)

def solution():
	for i in range(Int()):
		(n, k) = Mint()
		a = List()
		m = max(a)
		for i in range(n):
			a[i] = m - a[i]
		if k % 2 == 0:
			m = max(a)
			for i in range(n):
				a[i] = m - a[i]
		print(*a)
solution()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	even = []
	odd = []
	x = max(l)
	for i in range(n):
		l[i] = x - l[i]
		odd.append(l[i])
	odd = tuple(odd)
	x = max(l)
	for i in range(n):
		l[i] = x - l[i]
		even.append(l[i])
	even = tuple(even)
	if k % 2:
		l = odd
	else:
		l = even
	for i in range(n):
		print(l[i], end=' ')
	print()


for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	m = min(a)
	a = [i - m for i in a]
	m = max(a)
	if k % 2:
		b = [str(m - i) for i in a]
		print(' '.join(b))
	else:
		b = [str(i) for i in a]
		print(' '.join(b))


T = int(input())
for case in range(T):
	(m, n) = [int(x) for x in input().split()]
	ls = [int(x) for x in input().split()]
	ret = [[x for x in ls]]
	for i in range(2):
		M = max(ret[-1])
		ret.append([M - x for x in ret[-1]])
	if n % 2:
		print(' '.join([str(x) for x in ret[1]]))
	else:
		print(' '.join([str(x) for x in ret[2]]))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	m = max(l)
	l = list(map(lambda x: m - x, l))
	if k % 2 == 0:
		m = max(l)
		l = list(map(lambda x: m - x, l))
	print(*l)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	m = max(arr)
	for i in range(n):
		arr[i] = m - arr[i]
	arr1 = arr.copy()
	m = max(arr1)
	for i in range(n):
		arr1[i] = m - arr1[i]
	if k % 2 == 0:
		print(*arr1)
	else:
		print(*arr)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	maxi = max(a)
	mini = min(a)
	if k == 0:
		print(*a)
	elif k % 2 == 0:
		a = [i - mini for i in a]
		print(*a)
	else:
		a = [maxi - i for i in a]
		print(*a)


import math

def shrey():
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	a = list(map(int, input().split()))
	d = max(a)
	b = []
	c = []
	m = (k - 1) % 2
	for i in range(n):
		b.append(abs(d - a[i]))
	q = max(b)
	for i in range(n):
		c.append(q - b[i])
	if k % 2 == 0:
		for i in range(n):
			print(c[i], end=' ')
		print()
	else:
		for i in range(n):
			print(b[i], end=' ')
		print()
T = input()
T = int(T)
for q in range(1, T + 1):
	shrey()


def inf_arr(a, l, no):
	if no % 2 == 0:
		mi = min(a)
		for j in range(0, l):
			a[j] = a[j] - mi
	else:
		ma = max(a)
		for j in range(0, l):
			a[j] = ma - a[j]
	return a
n = int(input())
res = []
for _ in range(0, n):
	inp = input().split()
	l = int(inp[0])
	no = int(inp[1])
	arr = list(map(int, input().split()))
	res.append(inf_arr(arr, l, no))
for i in res:
	for j in i:
		print(j, end=' ')
	print()


INF = 1000000000.0 + 10
t = int(input())
while t:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	mx = -INF
	mn = INF
	for x in a:
		mx = max(mx, x)
		mn = min(mn, x)
	if k % 2:
		for x in a:
			print(mx - x, end=' ')
		print()
	else:
		for x in a:
			print(x - mn, end=' ')
		print()
	t -= 1


def f(arr):
	d = max(arr)
	for i in range(len(arr)):
		arr[i] = d - arr[i]
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	if k <= 2:
		for i in range(k):
			f(arr)
	elif k % 2 == 1:
		for i in range(3):
			f(arr)
	else:
		for i in range(4):
			f(arr)
	print(*arr)


import math
T = int(input())
for i in range(T):
	(n, k) = map(int, input().split())
	a = list(map(int, list(input().split())))
	b = [0] * n
	d = False
	if k == 0:
		print(' '.join([str(i) for i in a]))
		continue
	ma = max(a)
	for i in range(n):
		b[i] = ma - a[i]
	if k % 2 == 0:
		ma = max(b)
		for i in range(n):
			b[i] = ma - b[i]
	print(' '.join([str(i) for i in b]))


t = int(input())
for j in range(t):
	(n, k) = map(int, input().split())
	listn = list(map(int, input().split()))
	max1 = max(listn)
	listodd = []
	listeven = []
	for i in range(n):
		listodd.append(max1 - listn[i])
	max2 = max(listodd)
	for i in range(n):
		listeven.append(max2 - listodd[i])
	if k % 2 == 0:
		for i in listeven:
			print(i, end=' ')
		print()
	else:
		for i in listodd:
			print(i, end=' ')
		print()


def con(w):
	d = []
	for s in w:
		s = str(s)
		d.append(s)
	return ' '.join(d)
t = int(input())
i = 0
while i < t:
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	a = list(map(int, input().split()))
	l = max(a)
	x = []
	p = []
	for s in a:
		x.append(l - s)
	o = max(x)
	for j in x:
		p.append(o - j)
	if k % 2 == 0:
		print(con(p))
	else:
		print(con(x))
	i += 1


for _ in range(int(input())):
	(n, k) = (int(x) for x in input().split())
	a = list((int(x) for x in input().split()))
	if k % 2 == 0:
		d = max(a)
		for i in range(n):
			a[i] = d - a[i]
		d = max(a)
		for i in range(n):
			a[i] = d - a[i]
	else:
		d = max(a)
		for i in range(n):
			a[i] = d - a[i]
	for i in range(n):
		print(a[i], end=' ')
	print('')


n = int(input())
for i in range(n):
	(q, w) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	if w == 0:
		print(*a)
	elif w % 2 == 1:
		m = max(a)
		a = [m - i for i in a]
		print(*a)
	else:
		m = max(a)
		a = [m - i for i in a]
		m = max(a)
		a = [m - i for i in a]
		print(*a)


T = int(input())
while T:
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	x = max(A)
	for i in range(n):
		A[i] = x - A[i]
	B = []
	y = max(A)
	for i in range(n):
		B.append(y - A[i])
	if k % 2 == 0:
		print(*B)
	else:
		print(*A)
	T = T - 1


from copy import copy

def main():
	for _ in range(int(input())):
		(n, k) = list(map(int, input().split()))
		a = list(map(int, input().split()))
		d = max(a)
		for i in range(n):
			a[i] = d - a[i]
		d1 = max(a)
		if k % 2 == 1:
			print(*a)
		else:
			for i in range(n):
				a[i] = d1 - a[i]
			print(*a)
main()


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	x = min(a)
	if k > 1:
		for i in range(n):
			a[i] = a[i] - x
		if k % 2 == 1:
			y = max(a)
			for i in range(n):
				a[i] = y - a[i]
	elif k == 1:
		y = max(a)
		for i in range(n):
			a[i] = y - a[i]
	for i in range(n):
		print(a[i], end=' ')
	print()


import sys
import math

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	(n, k) = get_ints()
	a = get_array()
	c = max(a)
	ans1 = []
	for i in range(n):
		ans1.append(c - a[i])
	d = max(ans1)
	ans = []
	for j in range(n):
		ans.append(d - ans1[j])
	if k % 2 != 0:
		print(*ans1)
	else:
		print(*ans)


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	if k > 2:
		k = 1 if k % 2 == 1 else 2
	for j in range(k):
		ma = max(A)
		A = [ma - A[ii] for ii in range(n)]
	print(*A)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def print_list(l):
	print(' '.join(map(str, l)))
for _ in range(N()):
	(n, k) = RL()
	a = RLL()
	d = max(a)
	res = [d - i for i in a]
	if k == 1:
		print_list(res)
	else:
		d = max(res)
		res = [d - i for i in res]
		if k & 1:
			print_list([d - i for i in res])
		else:
			print_list(res)


(z, zz) = (input, lambda : list(map(int, z().split())))
(szz, dgraphs, mod) = (lambda : sorted(zz()), {}, 10 ** 9 + 7)
from string import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
num = int(z())
for i in range(num):
	(n, k) = zz()
	l = zz()
	if k % 2 == 0:
		p = 1
	else:
		p = 0
	for i in range(1 + p):
		t = max(l)
		for i in range(n):
			l[i] = t - l[i]
	print(*l)


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 19
MOD = 10 ** 9 + 7
for _ in range(INT()):
	(N, K) = MAP()
	A = LIST()
	mx = max(A)
	B = [0] * N
	for i in range(N):
		B[i] = mx - A[i]
	if K == 1:
		print(*B)
		continue
	mx = max(B)
	C1 = [0] * N
	C2 = [0] * N
	for i in range(N):
		C1[i] = mx - B[i]
	if K == 2:
		print(*C1)
		continue
	for i in range(N):
		C2[i] = mx - C1[i]
	if K % 2 == 0:
		print(*C1)
	else:
		print(*C2)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	mx = max(l)
	if k % 2 == 1:
		for i in l:
			print(mx - i, end=' ')
		print()
	else:
		ans = []
		for i in l:
			ans += [mx - i]
		mx = max(ans)
		for i in ans:
			print(mx - i, end=' ')
		print()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	m = max(a)
	a = list(map(lambda x: m - x, a))
	if k & 1:
		print(*a)
	else:
		m = max(a)
		a = list(map(lambda x: m - x, a))
		print(*a)


t = int(input())
for hh in range(t):
	gg = [int(i) for i in input().split()]
	n = gg[0]
	k = gg[1]
	li = [int(i) for i in input().split()]
	maxi = max(li)
	for i in range(len(li)):
		li[i] = maxi - li[i]
	maxi = max(li)
	lii = []
	for i in range(len(li)):
		lii.append(maxi - li[i])
	if k % 2 == 1:
		for i in li:
			print(i, end=' ')
	else:
		for i in lii:
			print(i, end=' ')
	print()


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	m = max(a)
	l1 = []
	for i in range(n):
		l1.append(m - a[i])
	l2 = []
	m = max(l1)
	for i in range(n):
		l2.append(m - l1[i])
	if k % 2 == 1:
		print(*l1)
	else:
		print(*l2)


T = int(input())
for _ in range(T):
	(N, K) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	r = K % 2
	m = min(a)
	M = max(a)
	b = []
	if r == 0:
		b = [ai - m for ai in a]
	else:
		b = [M - ai for ai in a]
	print(*b)


t = int(input())
while t:
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	maxi = max(l)
	a1 = []
	a2 = []
	for i in l:
		a1.append(maxi - i)
	maxi1 = max(a1)
	for i in a1:
		a2.append(maxi1 - i)
	if k & 1:
		print(*a1)
	else:
		print(*a2)
	t -= 1


for i in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	if k % 2 == 1:
		m = max(arr)
		for i in range(0, len(arr)):
			arr[i] = m - arr[i]
		print(*arr)
	else:
		m1 = min(arr)
		for i in range(0, len(arr)):
			arr[i] = arr[i] - m1
		print(*arr)


for _ in [0] * int(input()):
	(n, k) = map(int, input().split())
	arr = [int(d) for d in input().split()]
	ma = max(arr)
	for i in range(n):
		arr[i] = ma - arr[i]
	if k == 1:
		for a in range(n):
			print(arr[a], end=' ')
			print()
	elif k % 2 == 1:
		ma = max(arr)
		for k in range(n):
			arr[k] = ma - arr[k]
		ma = max(arr)
		for l in range(n):
			arr[l] = ma - arr[l]
		for c in range(n):
			print(arr[c], end=' ')
		print()
	else:
		ma = max(arr)
		for j in range(n):
			arr[j] = ma - arr[j]
		for b in range(n):
			print(arr[b], end=' ')
		print()


import sys
T = int(sys.stdin.readline().strip())
for t in range(0, T):
	(n, k) = list(map(int, sys.stdin.readline().strip().split()))
	a = list(map(int, sys.stdin.readline().strip().split()))
	m = min(a)
	M = max(a)
	if k > 2:
		k = 1 + (k - 1) % 2
	if k == 1:
		for i in range(0, n):
			a[i] = M - a[i]
	if k == 2:
		for i in range(0, n):
			a[i] = a[i] - m
	print(' '.join(list(map(str, a))))


import sys

class BOmkarAndInfinityClock:

	def solve(self, tc=0):
		for _ in range(int(input())):
			(n, k) = [int(_) for _ in input().split()]
			a = [int(_) for _ in input().split()]
			(mn, mx) = (min(a), max(a))
			a = [mx - x for x in a]
			k -= 1
			d = max(a)
			if k % 2 == 0:
				print(*a)
			else:
				print(*[d - x for x in a])
solver = BOmkarAndInfinityClock()
input = sys.stdin.readline
solver.solve()


def op(a, n, k):
	M = max(a)
	for i in range(n):
		a[i] = M - a[i]
	k -= 1
	if k % 2 == 1:
		M = max(a)
		for i in range(n):
			a[i] = M - a[i]
	return ' '.join(list(map(str, a)))
t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().rstrip().split(' ')))
	a = list(map(int, input().rstrip().split(' ')))
	print(op(a, n, k))


t = int(input())
for z in range(t):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	if k % 2 == 0:
		for i in range(2):
			d = max(a)
			for j in range(n):
				a[j] = d - a[j]
	else:
		d = max(a)
		for j in range(n):
			a[j] = d - a[j]
	print(*a)


tc = int(input())
for i in range(tc):
	[n, k] = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	d = max(arr)
	if k % 2 == 1:
		for i in range(n):
			arr[i] = d - arr[i]
		print(*arr)
	else:
		for i in range(n):
			arr[i] = d - arr[i]
		d = max(arr)
		for i in range(n):
			arr[i] = d - arr[i]
		print(*arr)


R = lambda : map(int, input().split())
(t,) = R()
exec(t * 'n,k=R();a=*R(),;M=max(a);m=min(a);print(*((x-m,M-x)[k%2]for x in a));')


def solve(test):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	mx = max(a)
	k -= 1
	for i in range(n):
		a[i] = mx - a[i]
	if k % 2 > 0:
		mx = max(a)
		for i in range(n):
			a[i] = mx - a[i]
	print(*a)
t = 1
t = int(input())
for _ in range(t):
	solve(_ + 1)


import sys
readline = sys.stdin.readline
T = int(readline())
Ans = [None] * T
for qu in range(T):
	(N, K) = map(int, readline().split())
	A = list(map(int, readline().split()))
	K -= 1
	ma = max(A)
	A = [ma - a for a in A]
	if K & 1:
		ma = max(A)
		A = [ma - a for a in A]
	Ans[qu] = ' '.join(map(str, A))
print('\n'.join(Ans))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split(' '))
	arr = list(map(int, input().split(' ')))
	if k % 2 != 0:
		d = max(arr)
		for i in range(n):
			arr[i] = d - arr[i]
	else:
		for _ in range(2):
			d = max(arr)
			for i in range(n):
				arr[i] = d - arr[i]
	print(' '.join(map(str, arr)))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = [*map(int, input().split())]
	mx = max(arr) if k & 1 else min(arr)
	arr = [abs(mx - i) for i in arr]
	print(*arr)


for _ in range(int(input())):
	(n, k) = list(map(int, input().strip().split()))
	li1 = list(map(int, input().strip().split()))
	d = max(li1)
	li2 = list()
	for i in range(n):
		li2.append(d - li1[i])
	d = max(li2)
	li3 = list()
	for i in range(n):
		li3.append(d - li2[i])
	if k % 2 == 1:
		for i in range(len(li2)):
			print(li2[i], end=' ')
		print('')
	else:
		for i in range(len(li3)):
			print(li3[i], end=' ')
		print('')


import sys, math
input = lambda : sys.stdin.readline().rstrip()

def d(b):
	c = max(b)
	for i in range(n):
		b[i] = c - b[i]
	return b
for __ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	for i in range(2):
		a = d(a)
	for i in range(k % 2):
		a = d(a)
	print(*a)


testcases = int(input())
for testcase in range(testcases):
	temparr = input()
	temparr = temparr.split()
	n = int(temparr[0])
	k = int(temparr[1])
	flag = 1
	if k % 2 == 0:
		flag = 2
	arr = []
	temparr = input()
	temparr = temparr.split()
	for i in temparr:
		arr.append(int(i))
	for i in range(flag):
		maxs = max(arr)
		for j in range(n):
			arr[j] = maxs - arr[j]
	strs = []
	for i in arr:
		strs.append(str(i))
	print(' '.join(strs))


def chan():
	N = int(input())
	for i in range(N):
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		if a[1] % 2 == 1:
			c = max(b)
			for k in range(len(b)):
				b[k] = c - b[k]
			print(*b)
		elif a[1] % 2 == 0:
			for m in range(2):
				c = max(b)
				for j in range(len(b)):
					b[j] = c - b[j]
			print(*b)
chan()


for j in range(int(input())):
	(n, k) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	m = max(l)
	mi = m - min(l)
	oddl = [str(m - l[i]) for i in range(n)]
	evenl = [str(mi - int(oddl[i])) for i in range(n)]
	if k % 2 == 0:
		print(' '.join(evenl))
	else:
		print(' '.join(oddl))


t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	arr = input().split()
	arr = [int(i) for i in arr]
	if k % 2 == 1:
		max1 = max(arr)
		arr = [max1 - i for i in arr]
		print(*arr, sep=' ')
	else:
		max1 = max(arr)
		arr = [max1 - i for i in arr]
		max1 = max(arr)
		arr = [max1 - i for i in arr]
		print(*arr, sep=' ')
	t -= 1


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 10 ** 9 + 7
EPS = 1e-06

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	(n, k) = value()
	a = array()
	Max = max(a)
	Min = min(a)
	k -= 1
	a = [Max - i for i in a]
	D = Max - Min
	if k % 2:
		a = [D - i for i in a]
	print(*a)


import os
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from io import BytesIO, IOBase
from itertools import accumulate, combinations, combinations_with_replacement, groupby, permutations, product
from math import acos, asin, atan, ceil, cos, degrees, factorial, hypot, inf, log2, pi, radians, sin, sqrt, tan
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits

def inp():
	return int(input())

def inlist():
	return list(map(int, input().split()))

def instr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())

def main():
	t = inp()
	for _ in range(t):
		(n, k) = invr()
		a = inlist()
		mx = max(a)
		for i in range(n):
			a[i] = mx - a[i]
		b = []
		mx = max(a)
		for i in range(n):
			b.append(mx - a[i])
		if k % 2 != 0:
			print(*a)
		else:
			print(*b)
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	num = [int(x) for x in input().split()]
	d = max(num)
	for i in range(n):
		num[i] = d - num[i]
	num2 = num[:]
	d = max(num)
	for i in range(n):
		num2[i] = d - num2[i]
	if k == 1:
		print(*num)
		continue
	if k == 2:
		print(*num2)
		continue
	if k % 2 != 0:
		print(*num)
	else:
		print(*num2)


from sys import stdin, stdout
from math import gcd, sqrt, factorial
from collections import deque, defaultdict
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
lcm = lambda x, y: x * y // gcd(x, y)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 0 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
for _ in range(I()):
	(n, k) = R()
	a = L()
	mx = max(a)
	p = []
	p.append([mx - i for i in a])
	mx = max(p[0])
	p.append([mx - i for i in p[0]])
	print(*p[(k + 1) % 2])


def main():
	t = int(input())
	for tt in range(t):
		(n, k) = map(int, input().split())
		a = list(map(int, input().split()))
		ao = []
		ae = []
		mm = max(a)
		s = -100000000000
		for i in range(len(a)):
			m = mm - a[i]
			ao.append(str(m))
			s = max(s, m)
		for i in range(len(a)):
			dm = s - int(ao[i])
			ae.append(str(dm))
		if k % 2 == 1:
			print(' '.join(ao))
		else:
			print(' '.join(ae))
main()


aea = int(input())
for time in range(aea):
	(n, k) = input().split()
	(n, k) = (int(n), int(k))
	op = []
	fi = []
	se = []
	rt = input().split()
	op = rt
	for er in range(n):
		op[er] = int(op[er])
	d = max(op)
	for qe in range(n):
		op[qe] = d - op[qe]
	fi = op
	if k % 2 != 0:
		print(*fi)
		continue
	d = max(fi)
	for qe in range(n):
		op[qe] = d - op[qe]
	se = op
	if k % 2 == 0:
		print(*op)


from sys import exit, stdin, stderr

def rl():
	return [int(w) for w in stdin.readline().split()]
(T,) = rl()
for _ in range(T):
	(n, k) = rl()
	a = rl()
	d = max(a)
	a = [d - x for x in a]
	if k % 2 == 0:
		d = max(a)
		a = [d - x for x in a]
	print(*a)


from collections import defaultdict
from math import *
import os
import sys
from io import BytesIO, IOBase
from heapq import nlargest
from bisect import *
import copy
import itertools
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	if n == 1:
		print('0')
	else:
		m1 = max(arr)
		m2 = m1 + min(arr)
		for i in range(n):
			arr[i] = m1 - arr[i]
		m1 = max(arr)
		m2 = m1 + min(arr)
		if k == 1:
			for i in range(n):
				print(arr[i], end=' ')
			print()
		elif k % 2 == 0:
			for i in range(n):
				print(m1 - arr[i], end=' ')
			print()
		else:
			for i in range(n):
				print(m2 - m1 + arr[i], end=' ')
			print()


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	if k % 2 == 1:
		p = max(l)
		for j in range(n):
			q = l[j]
			l[j] = p - q
	else:
		for num in range(2):
			p = max(l)
			for j in range(n):
				q = l[j]
				l[j] = p - q
	print(*l)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	if len(set(l)) == 1:
		l = [0] * n
	elif k > 0:
		k = 1 if k % 2 else 2
		for i in range(k):
			d = max(l)
			for i in range(n):
				l[i] = d - l[i]
	print(*l)


def func(array, k):
	if k == 0:
		return array
	if k % 2 == 1:
		m = max(array)
		s = [m - q for q in array]
		return s
	if k % 2 == 0:
		m = min(array)
		s = [q - m for q in array]
		return s
t = int(input())
answer = []
for i in range(t):
	arr = list(map(int, input().rstrip().split()))
	n = arr[0]
	k = arr[1]
	array = list(map(int, input().rstrip().split()))
	ans = func(array, k)
	answer.append(ans)
for a in answer:
	print(*a)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	inp = [int(j) for j in input().split()]
	seq1 = []
	seq2 = []
	maxEle = max(inp)
	for i in range(n):
		seq1.append(maxEle - inp[i])
	maxEle2 = max(seq1)
	for i in range(n):
		seq2.append(maxEle2 - seq1[i])
	if k % 2 == 0:
		for i in seq2:
			print(i, end=' ')
	else:
		for i in seq1:
			print(i, end=' ')
	print()


for _ in range(int(input())):
	(n, d) = map(int, input().split())
	a = list(map(int, input().split()))
	odd = []
	even = []
	maxi = max(a)
	if d % 2 != 0:
		for i in range(0, len(a)):
			p = maxi - a[i]
			odd.append(p)
		print(*odd)
	else:
		for i in range(0, len(a)):
			p = maxi - a[i]
			odd.append(p)
		z = max(odd)
		for i in range(0, len(odd)):
			k = z - odd[i]
			even.append(k)
		print(*even)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	m = max(l)
	for i in range(n):
		l[i] = m - l[i]
	if k % 2 == 1:
		print(*l)
	else:
		m = max(l)
		for i in range(n):
			l[i] = m - l[i]
		print(*l)


from bisect import bisect_left, bisect_right
from itertools import combinations
from itertools import permutations
from bisect import bisect_left
from math import ceil
from math import radians
from heapq import heapify, heappush, heappop
import bisect
from math import pi
from collections import deque
from math import factorial
from math import log, ceil
from collections import defaultdict
from math import *
from sys import stdin, stdout
import itertools
import os
import sys
import threading
from collections import deque, Counter, OrderedDict, defaultdict
from heapq import *
from fractions import Fraction
mod = int(pow(10, 9) + 7)

def ii():
	return int(input())

def si():
	return str(input())

def mi():
	return map(int, input().split())

def li1():
	return list(mi())

def fii():
	return int(stdin.readline())

def fsi():
	return str(stdin.readline())

def fmi():
	return map(int, stdin.readline().split())

def fli():
	return list(fmi())
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000

def bfs(d, v):
	q = []
	q.append(v)
	visited[v] = 1
	while len(q) != 0:
		x = q[0]
		q.pop(0)
		for i in d[x]:
			if visited[i] != 1:
				visited[i] = 1
				q.append(i)
		print(x)

def make_graph(e):
	d = {}
	for i in range(e):
		(x, y) = mi()
		if x not in d:
			d[x] = [y]
		else:
			d[x].append(y)
		if y not in d:
			d[y] = [x]
		else:
			d[y].append(x)
	return d

def gr2(n):
	d = defaultdict(list)
	for i in range(n):
		(x, y) = mi()
		d[x].append(y)
	return d

def connected_components(graph):
	seen = set()

	def dfs(v):
		vs = set([v])
		component = []
		while vs:
			v = vs.pop()
			seen.add(v)
			vs |= set(graph[v]) - seen
			component.append(v)
		return component
	ans = []
	for v in graph:
		if v not in seen:
			d = dfs(v)
			ans.append(d)
	return ans

def primeFactors(n):
	s = set()
	while n % 2 == 0:
		s.add(2)
		n = n // 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0 and i % 2 == 1:
			s.add(i)
			n = n // i
	if n > 2 and n % 2 == 1:
		s.add(n)
	return s

def find_all(a_str, sub):
	start = 0
	while True:
		start = a_str.find(sub, start)
		if start == -1:
			return
		yield start
		start += len(sub)

def SieveOfEratosthenes(n, isPrime):
	isPrime[0] = isPrime[1] = False
	for i in range(2, n):
		isPrime[i] = True
	p = 2
	while p * p <= n:
		if isPrime[p] == True:
			i = p * p
			while i <= n:
				isPrime[i] = False
				i += p
		p += 1
	return isPrime

def dijkstra(edges, f, t):
	g = defaultdict(list)
	for (l, r, c) in edges:
		g[l].append((c, r))
	(q, seen, mins) = ([(0, f, ())], set(), {f: 0})
	while q:
		(cost, v1, path) = heappop(q)
		if v1 not in seen:
			seen.add(v1)
			path = (v1, path)
			if v1 == t:
				return (cost, path)
			for (c, v2) in g.get(v1, ()):
				if v2 in seen:
					continue
				prev = mins.get(v2, None)
				next = cost + c
				if prev is None or next < prev:
					mins[v2] = next
					heappush(q, (next, v2, path))
	return float('inf')

def binsearch(a, l, r, x):
	while l <= r:
		mid = l + (r - 1) // 2
		if a[mid]:
			return mid
		elif a[mid] > x:
			l = mid - 1
		else:
			r = mid + 1
	return -1

def readTree(n):
	adj = [set() for _ in range(n)]
	for _ in range(n - 1):
		(u, v) = map(int, input().split())
		adj[u - 1].add(v - 1)
		adj[v - 1].add(u - 1)
	return adj

def treeOrderByDepth(n, adj, root=0):
	parent = [-2] + [-1] * (n - 1)
	ordered = []
	q = deque()
	q.append(root)
	depth = [0] * n
	while q:
		c = q.popleft()
		ordered.append(c)
		for a in adj[c]:
			if parent[a] == -1:
				parent[a] = c
				depth[a] = depth[c] + 1
				q.append(a)
	return (ordered, parent, depth)

def isSubSequence(str1, str2):
	m = len(str1)
	n = len(str2)
	j = 0
	i = 0
	while j < m and i < n:
		if str1[j] == str2[i]:
			j = j + 1
		i = i + 1
	return j == m

def nextPowerOf2(n):
	count = 0
	if n and (not n & n - 1):
		return n
	while n != 0:
		n >>= 1
		count += 1
	return 1 << count

def cou(n):
	c = 0
	while n > 1:
		c += 1
		n //= 2
	return c

def sortsec(l):
	return sorted(l, key=lambda x: x[1])

def BinarySearch(a, x):
	i = bisect_left(a, x)
	if i:
		return i - 1
	else:
		return -1

def subarray(A):
	r = set()
	p = {0}
	for x in A:
		p = {x | y for y in p} | {x}
		r |= p
	return len(r)
for _ in range(ii()):
	(n, k) = mi()
	l = li1()
	x = []
	y = []
	a = max(l)
	for i in l:
		x.append(a - i)
	b = max(x)
	for i in x:
		y.append(b - i)
	if k % 2 == 1:
		print(*x)
	else:
		print(*y)


t = int(input())
for _ in range(t):
	(n, k) = map(int, list(input().split()))
	A = list(map(int, list(input().split())))
	maxA = max(A)
	if k % 2 == 1:
		print(*[maxA - a for a in A])
	else:
		A = [maxA - a for a in A]
		maxA = max(A)
		print(*[maxA - a for a in A])


T = int(input())
for t in range(1, T + 1):
	string = input().split()
	N = int(string[0])
	K = int(string[1])
	lst = input().split()
	for i in range(N):
		lst[i] = int(lst[i])
	max_lst = max(lst)
	min_lst = min(lst)
	if K % 2 == 1:
		for i in range(N):
			if lst[i] == max_lst:
				lst[i] = 0
			elif lst[i] == min_lst:
				lst[i] = max_lst - lst[i]
			else:
				lst[i] = max_lst - lst[i]
	else:
		for i in range(N):
			if lst[i] == max_lst:
				lst[i] = max_lst - min_lst
			elif lst[i] == min_lst:
				lst[i] = 0
			else:
				lst[i] = lst[i] - min_lst
	for i in range(N):
		print(lst[i], '', end='')
	print()


for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	l = [int(x) for x in input().split()]
	p = max(l)
	for i in range(n):
		l[i] = p - l[i]
	if k == 1:
		print(*l, sep=' ')
	else:
		m = [i for i in l]
		f = max(m)
		for j in range(n):
			m[j] = f - m[j]
		if k % 2 == 1:
			print(*l, sep=' ')
		else:
			print(*m, sep=' ')


for _ in range(int(input())):
	(n, k) = list(map(int, input().split(' ')))
	arr = list(map(int, input().split(' ')))
	for j in range(k % 2 + 2):
		max_val = max(arr)
		for l in range(len(arr)):
			arr[l] = max_val - arr[l]
	print(*arr, sep=' ')


import sys
sys.setrecursionlimit(10 ** 5)
input = lambda : sys.stdin.readline()[:-1]

def main():
	t = int(input())
	for case in range(t):
		(n, k) = [int(x) for x in input().split()]
		max = (-10) ** 9 - 1
		min = 10 ** 9 + 1
		A = []
		for (pos, ele) in enumerate(input().split()):
			ele = int(ele)
			if ele < min:
				min = ele
			if ele > max:
				max = ele
			A.append(ele)
		d = max
		for pos in range(n):
			A[pos] = d - A[pos]
		temp = max - min
		min = max - max
		max = temp
		k -= 1
		if k % 2 == 0:
			print(*A, sep=' ')
			continue
		else:
			print(*[max - x for x in A], sep=' ')
			continue
	return
main()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class union_find:

	def __init__(self, n):
		self.n = n
		self.rank = [0] * n
		self.parent = [int(j) for j in range(n)]

	def union(self, i, j):
		i = self.find(i)
		j = self.find(j)
		if self.rank[i] == self.rank[j]:
			self.parent[i] = j
			self.rank[j] += 1
		elif self.rank[i] > self.rank[j]:
			self.parent[j] = i
		else:
			self.parent[i] = j

	def find(self, i):
		temp = i
		if self.parent[temp] != temp:
			self.parent[temp] = self.find(self.parent[temp])
		return self.parent[temp]
from math import log2, ceil
from collections import deque, Counter as CC, defaultdict as dd
MOD = int(1000000000.0 + 7)
from copy import deepcopy

def main():
	for t in range(int(input())):
		(n, k) = [int(j) for j in input().split()]
		l = [int(j) for j in input().split()]
		a = []
		for i in range(5):
			d = max(l)
			for i in range(n):
				l[i] = d - l[i]
			a.append(deepcopy(l))
		if k <= 5:
			print(' '.join(map(str, a[k - 1])))
		elif (k - 5) % 2 == 0:
			print(' '.join(map(str, a[-1])))
		else:
			print(' '.join(map(str, a[-2])))
main()


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	a = max(A)
	for i in range(n):
		A[i] = a - A[i]
	b = max(A)
	B = [0 for i in range(n)]
	for i in range(n):
		B[i] = b - A[i]
	if k % 2 != 0:
		print(*A)
	else:
		print(*B)


def op(l):
	a = max(l)
	for i in range(len(l)):
		l[i] = a - l[i]
	return l
for t in range(int(input())):
	(n, k) = map(int, input().split())
	an = list(map(int, input().split()))
	ans = op(an)
	if k % 2 == 0:
		ans = op(an)
	print(' '.join(map(str, ans)))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	k -= 1
	maxx = max(a)
	for i in range(n):
		a[i] = maxx - a[i]
	if k % 2 == 0:
		for i in range(n):
			print(a[i], end=' ')
	else:
		maxx2 = max(a)
		for i in range(n):
			print(maxx2 - a[i], end=' ')
	print('')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ar = list(map(int, input().split()))
	if n == 1:
		p = ar[0]
	ar2 = [0] * n
	x1 = max(ar)
	for i in range(n):
		ar2[i] = x1 - ar[i]
	x = max(ar2)
	for i in range(n):
		ar[i] = x - ar2[i]
	if k % 2 == 0:
		print(*ar)
	else:
		print(*ar2)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	array = list(map(int, input().split()))
	(low, high) = (min(array), max(array))
	if k % 2:
		for i in range(len(array)):
			array[i] = high - array[i]
	else:
		for i in range(len(array)):
			array[i] -= low
	print(*array)


T = int(input())
for _ in range(0, T):
	(n, k) = list(map(int, input().split()))
	s = [int(x) for x in input().split()]
	kk = max(s)
	for i in range(0, len(s)):
		s[i] = kk - s[i]
	k -= 1
	if k % 2 == 0:
		print(*s)
	else:
		kk = max(s)
		for i in range(0, len(s)):
			s[i] = kk - s[i]
		print(*s)


import heapq as hq
from heapq import heappop, heappush
from collections import deque, defaultdict, Counter

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())

def subset_sum_count(arr, n, sum):
	dp = [[0 for _ in range(sum + 1)] for _ in range(n + 1)]
	for i in range(n + 1):
		for j in range(sum + 1):
			if j == 0:
				dp[i][j] = 1
			elif arr[i - 1] <= j:
				dp[i][j] = dp[i - 1][j - arr[i - 1]] + dp[i - 1][j]
			else:
				dp[i][j] = dp[i - 1][j]
	return dp[n][sum]

def prefix(a):
	pre = []
	pre.append(a[0])
	for i in range(1, len(a)):
		pre.append(pre[i - 1] + a[i])
	return pre

def binary_search(func, lo, hi, abs_prec=1e-07):
	while abs(hi - lo) > abs_prec:
		mi = lo + (hi - lo) / 2
		if func(mi):
			hi = mi
		else:
			lo = mi
	return (lo + hi) / 2

def ternary_search(func, lo, hi, abs_prec=1e-07):
	while abs(hi - lo) > abs_prec:
		lo_third = lo + (hi - lo) / 3
		hi_third = hi - (hi - lo) / 3
		if func(lo_third) < func(hi_third):
			lo = lo_third
		else:
			hi = hi_third
	return (lo + hi) / 2

def discrete_binary_search(func, lo, hi):
	while lo < hi:
		mi = lo + (hi - lo) // 2
		if func(mi):
			hi = mi
		else:
			lo = mi + 1
	return lo

def discrete_ternary_search(func, lo, hi):
	while lo <= hi:
		lo_third = lo + (hi - lo) // 3
		hi_third = lo + (hi - lo) // 3 + (1 if 0 < hi - lo < 3 else (hi - lo) // 3)
		if func(lo_third) < func(hi_third):
			lo = lo_third + 1
		else:
			hi = hi_third - 1
	return lo
	return -1

def right_rotate(a, s):
	return a[s:] + a[:s]

def dec_to_bin(x):
	return int(bin(x)[2:])

def str_to_integer_list(n):
	a = []
	for i in range(len(n)):
		a.append(int(n[i]))
	return a

def list_to_str(l):
	s = ''
	for i in l:
		s += str(i)
	return s

def dijkstra(s, N, E):
	visited = set()
	dist = {}
	for i in range(1, N + 1):
		dist[i] = 1 << 29
	queue = [(dist[i], i) for i in range(1, N + 1)]
	hq.heappush(queue, (0, s))
	dist[s] = 0
	while queue:
		(d, u) = hq.heappop(queue)
		if u in visited:
			continue
		for t in E[u]:
			(v, r) = t
			if dist[v] > d + r:
				dist[v] = d + r
				hq.heappush(queue, (dist[v], v))
		visited.add(u)
	return dist

def prime_sieve(n):
	flag = n % 6 == 2
	sieve = bytearray((n // 3 + flag >> 3) + 1)
	for i in range(1, int(n ** 0.5) // 3 + 1):
		if not sieve[i >> 3] >> (i & 7) & 1:
			k = 3 * i + 1 | 1
			for j in range(k * k // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
			for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
	return sieve

def prime_list(n):
	res = []
	if n > 1:
		res.append(2)
	if n > 2:
		res.append(3)
	if n > 4:
		sieve = prime_sieve(n + 1)
		res.extend((3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not sieve[i >> 3] >> (i & 7) & 1))
	return res

def dijkstra(n, graph, start):
	(dist, parents) = ([float('inf')] * n, [-1] * n)
	dist[start] = 0
	queue = [(0, start)]
	while queue:
		(path_len, v) = heappop(queue)
		if path_len == dist[v]:
			for (w, edge_len) in graph[v]:
				if edge_len + path_len < dist[w]:
					(dist[w], parents[w]) = (edge_len + path_len, v)
					heappush(queue, (edge_len + path_len, w))
	return (dist, parents)

def path(start, end, parent):
	path = [end]
	while path[-1] != start:
		path.append(parent[path[-1]])
	path.reverse()
	return path

def bfs(graph, start, goal):
	if start == goal:
		return [start]
	visited = {start}
	queue = deque([(start, [])])
	while queue:
		(current, path) = queue.popleft()
		visited.add(current)
		for neighbor in graph[current]:
			if neighbor == goal:
				return path + [current, neighbor]
			if neighbor in visited:
				continue
			queue.append((neighbor, path + [current]))
			visited.add(neighbor)
	return None
import os
import sys
from io import BytesIO, IOBase

def DecimalToBinary(n):

	def helper(n):
		if n == 0:
			return ''
		else:
			if n % 2 == 1:
				binaryDigit = '1'
			else:
				binaryDigit = '0'
			return helper(n // 2) + binaryDigit
	if n == 0:
		result = '0'
	else:
		result = helper(n)
	return result

def p(board):
	for i in range(8):
		s = ''
		for j in range(8):
			s += board[i][j]
		print(s)

def binaryToDecimal(n):
	return int(n, 2)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def solve(a, b):
	x = DecimalToBinary(a)
	y = DecimalToBinary(b)
	z = x + y
	l = y + x
	r = binaryToDecimal(z) - binaryToDecimal(l)
	return r

def mostFrequent(arr, n):
	arr.sort()
	max_count = 1
	res = arr[0]
	curr_count = 1
	for i in range(1, n):
		if arr[i] == arr[i - 1]:
			curr_count += 1
		else:
			if curr_count > max_count:
				max_count = curr_count
				res = arr[i - 1]
			curr_count = 1
	if curr_count > max_count:
		max_count = curr_count
		res = arr[n - 1]
	return res

def sub_lists(list1):
	sublist = [[]]
	for i in range(len(list1) + 1):
		for j in range(i + 1, len(list1) + 1):
			sub = list1[i:j]
			sublist.append(sub)
	return sublist

def check(s):
	n = len(s)
	if n == 1:
		return True
	return s == s[::-1]
for _ in range(inp()):
	(n, k) = invr()
	a = inlt()
	d = max(a)
	if k % 2 == 0:
		d = max(a)
		for i in range(n):
			a[i] = d - a[i]
		d = max(a)
		for i in range(n):
			a[i] = d - a[i]
		print(*a)
	else:
		d = max(a)
		for i in range(n):
			a[i] = d - a[i]
		print(*a)


t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	z = k % 2
	if z == 0:
		z = 2
	for j in range(z):
		maxEl = max(a)
		for x in range(n):
			a[x] = maxEl - a[x]
	print(' '.join(list(map(str, a))))


test = int(input())
for i in range(test):
	(n, k) = [int(x) for x in input().split()]
	vals = [int(x) for x in input().split()]
	if n == 1:
		print(0)
		continue
	else:
		d = max(vals)
		for i in range(n):
			vals[i] = d - vals[i]
		state1 = vals[:]
		d = max(vals)
		for i in range(n):
			vals[i] = d - vals[i]
		state2 = vals[:]
		if k % 2 == 0:
			v = map(str, state2)
			print(' '.join(v))
		else:
			v = map(str, state1)
			print(' '.join(v))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	lis = list(map(int, input().split()))
	max1 = max(lis)
	k -= 1
	for i in range(len(lis)):
		lis[i] = max1 - lis[i]
	if k == 0:
		for i in lis:
			print(i, end=' ')
		print()
		continue
	max1 = max(lis)
	k -= 1
	for i in range(len(lis)):
		lis[i] = max1 - lis[i]
	max1 = max(lis)
	if k == 0:
		for i in lis:
			print(i, end=' ')
		print()
		continue
	if k % 2 == 0:
		for i in lis:
			print(i, end=' ')
		print()
	else:
		for i in range(len(lis)):
			lis[i] = max1 - lis[i]
		for i in lis:
			print(i, end=' ')
		print()


t = int(input())
while t > 0:
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	q = max(a)
	if k % 2 != 0:
		for i in range(n):
			a[i] = q - a[i]
	else:
		for i in range(n):
			a[i] = q - a[i]
		r = max(a)
		for k in range(n):
			a[k] = r - a[k]
	for j in range(n):
		print(a[j], end=' ')
	print()
	t -= 1


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	m = max(l)
	n = []
	o = []
	for i in l:
		n.append(m - i)
	m = max(n)
	for i in n:
		o.append(m - i)
	if k % 2 == 0:
		print(*o)
	else:
		print(*n)


testcase = int(input())
result = [0] * testcase
for i in range(testcase):
	arr = list(map(int, input().split()))
	n = arr[0]
	k = arr[1]
	oddlist = list(map(int, input().split()))
	big = oddlist[0]
	evenlist = [0] * len(oddlist)
	for num in oddlist:
		if num > big:
			big = num
	for j in range(n):
		oddlist[j] = big - oddlist[j]
		evenlist[j] = oddlist[j]
	big = evenlist[0]
	for num in evenlist:
		if num > big:
			big = num
	for j in range(n):
		evenlist[j] = big - evenlist[j]
	if k % 2 == 0:
		result[i] = evenlist
	else:
		result[i] = oddlist
for res in result:
	print(*res)


t = int(input())
for _ in range(t):
	(n, k) = [int(p) for p in input().split()]
	arr = [int(p) for p in input().split()]
	if len(arr) == 1:
		print(0)
		continue
	m = max(arr)
	currMax = 0
	prev = arr.copy()
	nex = arr.copy()
	for i in range(len(arr)):
		prev[i] = m - arr[i]
		currMax = max(currMax, m - arr[i])
	for i in range(len(arr)):
		nex[i] = currMax - prev[i]
	if k > 0:
		if k % 2 != 0:
			print(*prev)
		else:
			print(*nex)


n = int(input())
for i in range(n):
	(a, b) = [int(i) for i in input().split()]
	c = [int(i) for i in input().split()]
	d = max(c)
	for j in range(0, len(c)):
		c[j] = d - c[j]
	if b % 2 != 0:
		print(*c)
	else:
		d = max(c)
		for k in range(0, len(c)):
			c[k] = d - c[k]
		print(*c)


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(m,) = I()
while m:
	m -= 1
	(x, y) = I()
	arr = I()
	maxi = max(arr)
	odd = [maxi - i for i in arr]
	if y % 2 == 0:
		k = max(odd)
		print(*[k - i for i in odd])
	else:
		print(*odd)


T = int(input())
for _ in range(T):
	(N, K) = map(int, input().split())
	A = [int(a) for a in input().split()]
	m = max(A)
	A = [m - a for a in A]
	if K % 2 == 0:
		m = max(A)
		A = [m - a for a in A]
	print(*A)


def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = mpos(sum_so_far, current_sum)
	return sum_so_far

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum
from math import *
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	mm = max(a)
	b = [mm - i for i in a]
	mm = max(b)
	c = [mm - i for i in b]
	if k & 1:
		print(*b)
	else:
		print(*c)


import os
import sys
import math
import heapq
from decimal import *
from io import BytesIO, IOBase
from collections import defaultdict, deque

def r():
	return int(input())

def rm():
	return map(int, input().split())

def rl():
	return list(map(int, input().split()))
for _ in range(r()):
	(n, k) = rm()
	a = rl()
	b = [[j, i] for (i, j) in enumerate(a)]
	b.sort(reverse=True)
	c = b[0][0]
	d = []
	for i in b:
		d.append([c - i[0], i[1]])
	if k % 2 == 1:
		d.sort(key=lambda x: x[1])
		for i in d:
			print(i[0], end=' ')
		print()
	else:
		c = d[-1][0]
		e = []
		for i in d:
			e.append([c - i[0], i[1]])
		e.sort(key=lambda x: x[1])
		for i in e:
			print(i[0], end=' ')
		print()


for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	m = max(a)
	if k % 2 != 0:
		for i in range(n):
			a[i] = m - a[i]
	else:
		for i in range(n):
			a[i] = m - a[i]
		m2 = max(a)
		for i in range(n):
			a[i] = m2 - a[i]
	print(*a)


from sys import stdin
input = stdin.readline

def A():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		if len(set(a)) == 1:
			print(n)
		else:
			print(1)

def B():
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		a = list(map(int, input().split()))
		d = max(a)
		for i in range(n):
			a[i] = d - a[i]
		if k % 2 == 1:
			print(*a)
		d = max(a)
		for i in range(n):
			a[i] = d - a[i]
		if k % 2 == 0:
			print(*a)

def C():
	t = int(input())
	for _ in range(t):
		print(0)

def D():
	t = int(input())
	for _ in range(t):
		print(0)
B()


for i in range(int(input())):
	l1 = []
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	d = max(l)
	for j in range(n):
		l[j] = d - l[j]
	d = max(l)
	if k % 2 == 0:
		for j in range(n):
			l[j] = d - l[j]
	for j in l:
		print(j, end=' ')
	print()


case = int(input())
for i in range(case):
	(n, k) = map(int, input().split(' '))
	arr = list(map(int, input().split(' ')))
	maxElement = max(arr)
	arr = [maxElement - arr[i] for i in range(n)]
	k = k - 1
	if k % 2 == 0:
		for num in arr:
			print(num, end=' ')
	else:
		maxElement = max(arr)
		for num in arr:
			print(maxElement - num, end=' ')
	print()


def pr(l):
	for i in l:
		print(i, end=' ')
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ar = list(map(int, input().split()))
	M = max(ar)
	m = min(ar)
	if k == 0:
		pass
	elif k % 2 == 1:
		ar = [M - x for x in ar]
	else:
		ar = [x - m for x in ar]
	pr(ar)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	max1 = max(a)
	min1 = min(a)
	finalmax = max1 - min1
	ans = list()
	if k % 2 == 1:
		for j in range(n):
			x = max1 - a[j]
			ans.append(x)
	else:
		for j in range(n):
			x = finalmax - (max1 - a[j])
			ans.append(x)
	print(*ans)


MOD = 1000000007
from collections import defaultdict as dd, Counter, deque

def si():
	return input()

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))

def mi():
	return map(int, input().split())

def out(v):
	print(v)

def spout():
	print(v, end=' ')

def d2b(n):
	return bin(n).replace('0b', '')

def twod(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def vow():
	return ['a', 'e', 'i', 'o', 'u']

def let():
	return [chr(i) for i in range(97, 123)]

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def ispow2(x):
	return x and (not x & x - 1)

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)
t = ii()
while t:
	t -= 1
	(n, k) = mi()
	a = li()
	m = max(a)
	m1 = -1
	for i in a:
		if m - i > m1:
			m1 = m - i
	if k % 2 == 1:
		print(' '.join((str(m - i) for i in a)))
	else:
		print(' '.join((str(m1 - m + i) for i in a)))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import gcd, ceil

def pre(s):
	n = len(s)
	pi = [0] * n
	for i in range(1, n):
		j = pi[i - 1]
		while j and s[i] != s[j]:
			j = pi[j - 1]
		if s[i] == s[j]:
			j += 1
		pi[i] = j
	return pi

def prod(a):
	ans = 1
	for each in a:
		ans = ans * each
	return ans

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
for _ in range(int(input()) if True else 1):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	mx = max(a)
	while k:
		k -= 1
		mx2 = mx - a[0]
		for i in range(n):
			a[i] = mx - a[i]
			mx2 = max(a[i], mx2)
		if mx2 == mx:
			break
		mx = mx2
	if k == 0:
		print(*a)
	elif k % 2:
		for i in range(n):
			a[i] = mx - a[i]
		print(*a)
	else:
		print(*a)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	ma = -10000000000
	mi = 10000000000
	for j in range(n):
		if l[j] > ma:
			ma = l[j]
		if l[j] < mi:
			mi = l[j]
	for j in range(n):
		l[j] = ma - l[j]
	ma = ma - mi
	if k % 2 == 0:
		for j in range(n):
			l[j] = ma - l[j]
	print(*l)


import sys, io, os, time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect, math, heapq
alphabet = 'abcdefghijklmnopqrstuvwxyz'
input = sys.stdin.readline
for ii in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	ans = [0] * n
	m = max(arr)
	d = m
	for i in range(n):
		ans[i] = m - arr[i]
	if k & 1:
		print(*ans)
	else:
		d = max(ans)
		for i in range(n):
			ans[i] = d - ans[i]
		print(*ans)


T = int(input())
for t in range(T):
	(n, k) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	d = max(arr)
	for i in range(len(arr)):
		arr[i] = d - arr[i]
	if k % 2 == 1:
		print(*arr)
	else:
		d = max(arr)
		for i in range(len(arr)):
			arr[i] = d - arr[i]
		print(*arr)


import sys, math as mt
import heapq as hp
import collections as cc
import bisect as bi
import math as mt
import itertools as it
I = lambda : list(map(int, input().split()))
for tc in range(int(input())):
	(n, d) = I()
	l = I()
	first = l.copy()
	k = max(first)
	for i in range(n):
		first[i] = k - first[i]
	second = first.copy()
	kk = max(second)
	for i in range(n):
		second[i] = kk - second[i]
	if d % 2:
		print(*first)
	else:
		print(*second)


for u in range(int(input())):
	(n, k) = map(int, input().split())
	x = [int(w) for w in input().split()]
	if n == 1:
		print(0)
	else:
		y = []
		temp = max(x)
		for i in range(n):
			y.append(temp - x[i])
		temp = max(y)
		z = []
		for i in range(n):
			z.append(temp - y[i])
		if k % 2 == 1:
			print(*y)
		else:
			print(*z)


from copy import deepcopy
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	ma = max(a)
	for i in range(n):
		a[i] = ma - a[i]
	k -= 1
	a2 = deepcopy(a)
	ma2 = max(a2)
	for i in range(n):
		a2[i] = ma2 - a2[i]
	if k % 2 == 0:
		print(*a)
	else:
		print(*a2)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	m = max(a)
	a = [m - a for a in a]
	for _ in range(1 + k % 2):
		m = max(a)
		a = [m - a for a in a]
	print(*a)


def printList(l):
	for i in l:
		print(i, end=' ')
	print()
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	if k == 0:
		printList(a)
	mx = max(a)
	a = [mx - i for i in a]
	if k % 2 == 0:
		mx = max(a)
		a = [mx - i for i in a]
		printList(a)
	else:
		printList(a)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = list()
	if k % 2:
		k = 1
	else:
		k = 2
	for _ in range(k):
		d = max(a)
		for i in range(n):
			v = a[i]
			a[i] = d - v
	print(*a)


def result(A):
	for a in A:
		print(a, end=' ')
	print()
for t in range(int(input())):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	mx = -10 ** 9 - 1
	mn = 10 ** 9 + 1
	for a in A:
		mx = max(mx, a)
		mn = min(mn, a)
	if mx == mn:
		for i in range(n):
			A[i] = 0
		result(A)
		continue
	if mn != 0:
		k -= 1
		for i in range(n):
			A[i] = mx - A[i]
	if mn != 0:
		mx -= mn
	if k % 2 != 0:
		for i in range(n):
			A[i] = mx - A[i]
	result(A)


tc = int(input())
for i in range(tc):
	(nes, kes) = map(int, input().split())
	letletel = [int(i) for i in input().split()]
	aaa = max(letletel)
	for i in range(len(letletel)):
		letletel[i] = aaa - letletel[i]
	if kes % 2 == 1:
		print(*letletel)
	else:
		aaa = max(letletel)
		for i in range(len(letletel)):
			letletel[i] = aaa - letletel[i]
		print(*letletel)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	mx = max(arr)
	for i in range(n):
		arr[i] = mx - arr[i]
	mx = max(arr)
	even = []
	for i in range(n):
		even.append(mx - arr[i])
	odd = []
	mx = max(even)
	for i in range(n):
		odd.append(mx - even[i])
	if k % 2:
		print(*odd)
	else:
		print(*even)


kase = int(input().strip())
while kase > 0:
	kase = kase - 1
	(n, k) = map(int, input().strip().split())
	a = list(map(int, input().split()))
	if k % 2 == 1:
		mx = max(a)
		a = list(map(lambda ai: str(mx - ai), a))
	else:
		mn = min(a)
		a = list(map(lambda ai: str(ai - mn), a))
	print(' '.join(a))


n = int(input())
for _ in range(n):
	(n, k) = map(int, input().split(' '))
	array = list(map(int, input().split(' ')))
	for i in range((k + 1) % 2 + 1):
		highest = max(array)
		array = [highest - a for a in array]
	print(*array)


import copy
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if n == 1:
		print(0)
	else:
		b = copy.deepcopy(a)
		max1 = max(a)
		for i in range(len(a)):
			a[i] = max1 - a[i]
		max2 = max(a)
		for i in range(len(b)):
			b[i] = max2 - a[i]
		if k % 2 == 0:
			print(*b, sep=' ')
		else:
			print(*a, sep=' ')


t = int(input())
while t > 0:
	t = t - 1
	[n, k] = input().split()
	n = int(n)
	k = int(k)
	a = input().split()
	for i in range(0, n):
		a[i] = int(a[i])
	ma = max(a)
	mi = min(a)
	if k % 2 == 0:
		for i in a:
			print(i - mi, end=' ')
		print()
	else:
		for i in a:
			print(ma - i, end=' ')
		print()


import sys
RI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
rw = lambda : sys.stdin.readline().strip().split()
ri = lambda : int(sys.stdin.readline().strip())
rs = lambda : sys.stdin.readline().strip()
from collections import defaultdict as df
import random
from queue import PriorityQueue as pq
from math import ceil
t = ri()
for _ in range(t):
	(n, k) = RI()
	l = RI()
	maxo = max(l)
	mini = min(l)
	m3 = maxo - mini
	for i in l:
		if i == maxo:
			if k % 2 == 0:
				print(m3, end=' ')
			else:
				print(0, end=' ')
		elif i == mini:
			if k % 2 == 0:
				print(0, end=' ')
			else:
				print(m3, end=' ')
		elif k % 2 == 1:
			print(maxo - i, end=' ')
		else:
			print(m3 - (maxo - i), end=' ')
	print()


for test in range(int(input())):
	(n, k) = map(int, input().strip().split(' '))
	l = list(map(int, input().strip().split(' ')))
	x = max(l)
	for i in range(len(l)):
		l[i] = x - l[i]
	if k % 2 != 0:
		for i in range(len(l)):
			print(l[i], end=' ')
		print()
	else:
		p = max(l)
		for i in range(len(l)):
			l[i] = p - l[i]
		for i in range(len(l)):
			print(l[i], end=' ')
		print()


def solve(n, k, A):
	if k % 2 != 0:
		m = max(A)
		for i in range(n):
			A[i] = m - A[i]
		return A
	else:
		for _ in range(2):
			m = max(A)
			for i in range(n):
				A[i] = m - A[i]
		return A
t = int(input())
while t:
	res = []
	(n, k) = map(int, input().split(' '))
	in_ = map(int, input().split(' '))
	for x in in_:
		res.append(int(x))
	print(*solve(n, k, res))
	t -= 1


t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	maxi = max(l)
	i = 0
	if k % 2 == 1:
		for i in range(len(l)):
			l[i] = maxi - l[i]
	else:
		for i in range(len(l)):
			l[i] = maxi - l[i]
		maxi = max(l)
		for i in range(len(l)):
			l[i] = maxi - l[i]
	for i in l:
		print(i, end=' ')
	print()
	t -= 1


import os
import heapq
import sys, threading
import math
import bisect
import operator
from collections import defaultdict
sys.setrecursionlimit(10 ** 5)
from io import BytesIO, IOBase

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def power(x, p, m):
	res = 1
	while p:
		if p & 1:
			res = res * x % m
		x = x * x % m
		p >>= 1
	return res

def inar():
	return [int(k) for k in input().split()]

def lcm(num1, num2):
	return num1 * num2 // gcd(num1, num2)

def main():
	t = int(input())
	for _ in range(t):
		(n, k) = inar()
		arr = inar()
		el = max(arr)
		for i in range(n):
			arr[i] = el - arr[i]
		if (k - 1) % 2 == 0:
			print(*arr)
		else:
			el = max(arr)
			for i in range(n):
				arr[i] = el - arr[i]
			print(*arr)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys
input = sys.stdin.readline

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0, hi=None):
	if hi == None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations

def solve():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if n == 1:
		print(0)
		return
	m = max(a)
	b = [m - x for x in a]
	m = max(b)
	c = [m - x for x in b]
	m = max(c)
	d = [m - x for x in c]
	if k == 1:
		print(*b)
		return
	else:
		k -= 1
		if k % 2 == 0:
			print(*d)
		else:
			print(*c)
for _ in range(int(input())):
	solve()


for _ in range(int(input())):
	(N, k) = list(map(int, input().split()))
	A = list(map(int, input().split()))
	if (k - 1) % 2 == 0:
		t = max(A)
		for i in range(N):
			print(t - A[i], end=' ')
		print()
	else:
		t = max(A)
		for i in range(N):
			A[i] = t - A[i]
		t = max(A)
		for i in range(N):
			print(t - A[i], end=' ')
		print()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = [int(i) for i in input().split()]
	if n == 1:
		print(0)
	else:
		m = max(arr)
		l = []
		for i in arr:
			l.append(m - i)
		if k % 2 != 0:
			print(*l)
		else:
			c = max(l)
			r = [c - j for j in l]
			print(*r)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	if k % 2:
		t = max(l)
		for i in range(n):
			l[i] = t - l[i]
		print(*l)
	else:
		t = max(l)
		for i in range(n):
			l[i] = t - l[i]
		t = max(l)
		for i in range(n):
			l[i] = t - l[i]
		print(*l)


def main():
	(n, k) = map(int, input().split(' '))
	a = [int(x) for x in input().split(' ')]
	if k == 0:
		return a
	if k % 2 == 1:
		ma = max(a)
		return [ma - ai for ai in a]
	else:
		ma = min(a)
		return [ai - ma for ai in a]
for _ in range(int(input())):
	print(*main())


def solve():
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	d = max(A)
	for i in range(len(A)):
		A[i] = d - A[i]
	k -= 1
	k %= 2
	for i in range(k):
		d = max(A)
		for j in range(len(A)):
			A[j] = d - A[j]
	return ' '.join((str(num) for num in A))
tc = int(input())
for _ in range(tc):
	print(solve())


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	d = max(l)
	a = [d - l[i] for i in range(n)]
	d = max(a)
	b = [d - a[i] for i in range(n)]
	if k % 2 == 0:
		for i in range(n):
			print(b[i], end=' ')
	else:
		for i in range(n):
			print(a[i], end=' ')
	print()


T = int(input())
for _ in range(T):
	(N, k) = map(int, input().split())
	A = list(map(int, input().split()))
	m = max(A)
	ans = []
	for i in range(N):
		ans.append(m - A[i])
	ans1 = []
	m = max(ans)
	for i in range(N):
		ans1.append(m - ans[i])
	if k % 2 == 1:
		print(*ans)
	else:
		print(*ans1)


from sys import stdin, stdout
input = stdin.readline
print = stdout.write
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	mx = max(a)
	for i in range(n):
		a[i] = mx - a[i]
	if k & 1 == 0:
		mx = max(a)
		for i in range(n):
			a[i] = mx - a[i]
	a = ' '.join(list(map(str, a)))
	print(a)
	print('\n')


try:
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		arr = [int(x) for x in input().split()]
		if k == 1:
			d = max(arr)
			arr = list(map(lambda x: d - x, arr))
			for i in arr:
				print(i, end=' ')
		elif k >= 2:
			d = max(arr)
			for i in range(n):
				arr[i] = d - arr[i]
			arr1 = [0] * n
			d = max(arr)
			for j in range(n):
				arr1[j] += d - arr[j]
			if k % 2 == 0:
				for i in arr1:
					print(i, end=' ')
			else:
				for i in arr:
					print(i, end=' ')
except:
	pass


import sys

def main():
	t = Iint()
	for _ in range(t):
		(n, k) = Imap()
		a = Ilist()
		ma = max(a)
		a = [ma - ai for ai in a]
		if k % 2 == 1:
			Plist(a)
		elif k % 2 == 0:
			ma = max(a)
			a = [ma - ai for ai in a]
			Plist(a)
en = enumerate
FIO = 10

def debug(*args, c=6):
	pass
	print('\x1b[3{}m'.format(c), *args, '\x1b[0m', file=sys.stderr)
BUFSIZE = 8 * 1024

def Istr():
	return input()

def Iint():
	return int(input())

def Ilist():
	return list(map(int, input().split()))

def Imap():
	return map(int, input().split())

def Plist(li, s=' '):
	print(s.join(map(str, li)))
if not FIO:
	if __name__ == '__main__':
		main()
		exit()
else:
	from io import BytesIO, IOBase
	import os

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	forodd = 0
	foreven = 0
	maxima = max(arr)
	for i in range(n):
		arr[i] = maxima - arr[i]
	forodd = arr.copy()
	maxima = max(arr)
	for i in range(n):
		arr[i] = maxima - arr[i]
	foreven = arr
	if k % 2 == 0:
		print(*foreven)
	else:
		print(*forodd)
	t -= 1


n_sets = int(input())
for i in range(n_sets):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	max_a = max(arr)
	min_a = min(arr)
	delta = max_a - min_a
	if k % 2 == 1:
		for x in arr:
			print(max_a - x, end=' ')
	else:
		for x in arr:
			print(x - min_a, end=' ')
	print()


ttt = int(input())
for _ in range(ttt):
	(n, k) = [int(x) for x in input().split()]
	l = list([int(x) for x in input().split()])
	x = len(l)
	if x == 1:
		print(0)
	else:
		m = max(l)
		nl = list()
		for i in range(n):
			l[i] = m - l[i]
			nl.append(i)
		if k % 2 == 0:
			m = max(l)
			for i in l:
				print(m - i, end=' ')
		else:
			for i in l:
				print(i, end=' ')
		print()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	List = [int(x) for x in input().split()]
	Max = max(List)
	First = [Max - i for i in List]
	if k == 1:
		print(*First)
		continue
	Max = max(First)
	Second = [Max - i for i in First]
	if k & 1:
		print(*First)
	else:
		print(*Second)


from sys import stdin, stdout, setrecursionlimit
from math import gcd, ceil, sqrt
from collections import Counter, deque
from bisect import bisect_left, bisect_right
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
setrecursionlimit(100000)
mod = 1000000007
tc = ii1()
for _ in range(tc):
	(n, k) = iia()
	arr = iia()
	cur = max(arr)
	for i in range(len(arr)):
		arr[i] = cur - arr[i]
	one = arr[:]
	cur = max(arr)
	for i in range(len(arr)):
		arr[i] = cur - arr[i]
	two = arr[:]
	if k % 2 == 0:
		print(*two)
	else:
		print(*one)


a = int(input())
for i in range(a):
	(x, y) = map(int, input().split())
	l = list(map(int, input().split()))
	ma = max(l)
	for j in range(x):
		l[j] = ma - l[j]
	if y % 2 == 0:
		ma = max(l)
		for j in range(x):
			l[j] = ma - l[j]
	for j in l:
		print(j, end=' ')
	print()


for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	m = max(a)
	for i in range(n):
		a[i] = m - a[i]
	if k & 1:
		print(*a)
	else:
		m = max(a)
		for i in range(n):
			a[i] = m - a[i]
		print(*a)


from sys import stdin, stdout
t = int(stdin.readline().strip())
for _ in range(t):
	(n, k) = map(int, stdin.readline().strip().split(' '))
	arr = list(map(int, stdin.readline().strip().split(' ')))
	arr1 = sorted(arr)
	mm = arr1[-1] - arr1[0]
	for i in range(n):
		arr[i] = arr[i] - arr1[0]
	if k % 2 == 0:
		for i in arr:
			stdout.write(str(i) + ' ')
	else:
		for i in arr:
			stdout.write(str(mm - i) + ' ')
	stdout.write('\n')


answer = []
t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split(' ')))
	liste = list(map(int, input().split(' ')))
	m = max(liste)
	liste = [liste[i] for i in range(n)]
	benchmark1 = [m - liste[i] for i in range(n)]
	m2 = max(benchmark1)
	benchmark2 = [m2 - benchmark1[i] for i in range(n)]
	benchmark2 = [str(element) for element in benchmark2]
	benchmark1 = [str(element) for element in benchmark1]
	if k % 2 == 0:
		tempo = benchmark2
	else:
		tempo = benchmark1
	stri = ' '.join(tempo)
	answer.append(stri)
print('\n'.join(answer))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	maxi = a[0]
	for i in a:
		if maxi < i:
			maxi = i
	mx = maxi - a[0]
	for i in range(n):
		a[i] = maxi - a[i]
		if a[i] > mx:
			mx = a[i]
	mini = 0
	maxi = mx
	if k % 2 == 0:
		for i in range(n):
			a[i] = maxi - a[i]
	print(*a)


def clock_of_infinity(a, n, k):
	m = max(a)
	for i in range(len(a)):
		a[i] = m - a[i]
	if k % 2 == 1:
		return a
	m = max(a)
	return [m - el for el in a]
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	print(*clock_of_infinity(a, n, k))


import math
t = int(input())
for w in range(t):
	(n, k) = (int(i) for i in input().split())
	l = [int(i) for i in input().split()]
	m = max(l)
	for i in range(n):
		l[i] = m - l[i]
	k -= 1
	if k % 2 == 0:
		print(*l)
	else:
		m = max(l)
		for i in range(n):
			l[i] = m - l[i]
		print(*l)


for z in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	large = max(a)
	for i in range(n):
		a[i] = large - a[i]
	if (k - 1) % 2:
		large = max(a)
		for i in range(n):
			a[i] = large - a[i]
	for i in range(n):
		print(a[i], end=' ')
	print()


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	ar = [int(i) for i in input().split()]
	f = max(ar)
	for x in range(n):
		ar[x] = f - ar[x]
	if k % 2 == 1:
		print(' '.join((str(i) for i in ar)))
	else:
		f = max(ar)
		for x in range(n):
			ar[x] = f - ar[x]
		print(' '.join((str(i) for i in ar)))


from sys import stdin, stdout
from collections import defaultdict
import math
input = stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	maxi = max(l)
	l1 = [maxi - i for i in l]
	maxi = max(l1)
	l2 = [maxi - i for i in l1]
	if k % 2 == 0:
		print(*l2)
	else:
		print(*l1)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	k2 = k % 2
	if k2 == 1:
		for i in range(1):
			MAX = max(a)
			for j in range(len(a)):
				a[j] = MAX - a[j]
	elif k2 == 0:
		for i in range(2):
			MAX = max(a)
			for j in range(len(a)):
				a[j] = MAX - a[j]
	print(*a)


t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr1 = []
	m = max(arr)
	for i in arr:
		arr1.append(m - i)
	arr2 = []
	m = max(arr1)
	for i in arr1:
		arr2.append(m - i)
	if k % 2 == 1:
		for i in arr1:
			print(i, end=' ')
	else:
		for i in arr2:
			print(i, end=' ')
	t -= 1
	print('')


def fun(l, n):
	mx = max(l)
	mn = min(l)
	ls = l
	num = mx - mn
	odd = [mx - i for i in ls]
	evn = [num - i for i in odd]
	if n % 2 == 0:
		print(*evn)
	else:
		print(*odd)
T = int(input())
for _ in range(T):
	i = input().split()
	i = list(map(int, i))
	n = i[1]
	x = input().split(' ')
	x = list(map(int, x))
	fun(x, n)


import sys
import bisect as bi
import math
from collections import defaultdict as dd
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 5)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
s1 = 'abcdefghijklmnopqrstuvwxyz'
res = []
ans = []

def solve(targ, ans, res, l):
	if targ < 0:
		return []
	if targ == 0:
		if ans < res:
			ans = res
		return ans
	for i in range(25, -1, -1):
		if targ - l[i] >= 0:
			x = res.append(s1[i])
			if len(solve(targ - l[i], ans, x, l)) > 0:
				return ans
	return []
for _ in range(inin()):
	(n, k) = cin()
	l = ain()
	sarr = [0] * n
	ma = max(l)
	tarr = [0] * n
	for i in range(n):
		sarr[i] = ma - l[i]
	ma2 = max(sarr)
	for i in range(n):
		tarr[i] = ma2 - sarr[i]
	if k % 2 == 1:
		print(*sarr)
	else:
		print(*tarr)


import sys, os
cases = int(sys.stdin.readline())
for x in range(cases):
	(size, ops) = sys.stdin.readline()[:-1].split(' ')
	ops = int(ops)
	size = int(size)
	arr = sys.stdin.readline()[:-1].split(' ')
	arr = [int(c) for c in arr]
	if ops < 4:
		for c in range(ops):
			d = max(arr)
			for num in range(len(arr)):
				arr[num] = d - arr[num]
		for c in arr:
			print(c, end=' ')
		print()
	else:
		if (ops - 1) % 2 == 0:
			even = False
		else:
			even = True
		for c in range(2):
			d = max(arr)
			for num in range(len(arr)):
				arr[num] = d - arr[num]
		if even:
			for c in arr:
				print(c, end=' ')
			print()
		else:
			d = max(arr)
			for num in range(len(arr)):
				arr[num] = d - arr[num]
			for c in arr:
				print(c, end=' ')
			print()


from sys import stdin, stdout
input = stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	m = max(a)
	a1 = [m - a[i] for i in range(n)]
	m = max(a1)
	a2 = [m - a1[i] for i in range(n)]
	if k % 2:
		print(*a1)
	else:
		print(*a2)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split(' ')))
	A = list(map(int, input().split(' ')))
	(MAX, MIN) = (max(A), min(A))
	if k % 2 == 1:
		for i in range(n):
			A[i] = MAX - A[i]
	else:
		for i in range(n):
			A[i] = -MIN + A[i]
	for i in range(n):
		print(A[i], end=' ')
	print()


for i in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	m = max(a)
	for (i, val) in enumerate(a):
		a[i] = m - a[i]
	k -= 1
	if k % 2 == 0:
		print(' '.join((str(num) for num in a)))
	else:
		m = max(a)
		print(' '.join((str(m - num) for num in a)))


for t in range(int(input())):
	(n, k) = [int(k) for k in input().split()]
	arr = [int(k) for k in input().split()]
	maxarr = max(arr)
	arr1 = [maxarr - k for k in arr]
	maxarr1 = max(arr1)
	arr2 = [maxarr1 - k for k in arr1]
	if k % 2 == 0:
		print(*arr2)
	else:
		print(*arr1)


t = int(input())
while t > 0:
	t -= 1
	l = [int(x) for x in input().split()]
	(n, k) = (l[0], l[1])
	a = [int(x) for x in input().split()]
	mx = max(a)
	a1 = [mx - x for x in a]
	mx = max(a1)
	a2 = [mx - x for x in a1]
	if k == 0:
		print(*a)
	elif k % 2 == 1:
		print(*a1)
	else:
		print(*a2)


from math import *
t = int(input())
while t:
	t = t - 1
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	lst = max(a)
	a = [lst - i for i in a]
	k = k - 1
	while k:
		m = max(a)
		if m == lst:
			if k % 2:
				a = [m - i for i in a]
			break
		else:
			lst = m
			k = k - 1
			a = [m - i for i in a]
	for i in a:
		print(i, end=' ')
	print()


def solve():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))

	def do(u):
		j = max(u)
		return [j - i for i in u]
	b = []
	b.append(do(a))
	b.append(do(b[-1]))
	print(*b[(k - 1) % 2])
t = int(input())
for _ in range(t):
	solve()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	m = max(a)
	a = [m - x for x in a]
	if k == 1:
		print(*a)
		continue
	m = max(a)
	a = [m - x for x in a]
	k -= 1
	if k % 2:
		print(*a)
	else:
		m = max(a)
		a = [m - x for x in a]
		print(*a)


for _ in range(int(input())):
	li = list(map(int, input().split()))
	l = list(map(int, input().split()))
	m = max(l)
	ans = [m - i for i in l]
	ma = max(ans)
	ans1 = [ma - i for i in ans]
	if li[1] % 2 == 1:
		print(*ans)
	else:
		print(*ans1)


for test in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	t = max(a) if k % 2 else min(a)
	a = [abs(t - x) for x in a]
	print(*a)


from queue import Queue

def rn():
	a = int(input())
	return a

def rl():
	a = list(map(int, input().split()))
	return a
for _ in range(rn()):
	[n, k] = rl()
	a = rl()
	b = a.copy()
	c = max(a)
	for i in range(n):
		b[i] = c - b[i]
	c = max(b)
	d = b.copy()
	for i in range(n):
		d[i] = c - d[i]
	if k % 2 == 0:
		print(*d)
	else:
		print(*b)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	max_e = max(l)
	min_e = min(l)
	if k % 2 == 0:
		for i in range(n):
			l[i] = l[i] - min_e
	else:
		for i in range(n):
			l[i] = max_e - l[i]
	print(*l)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	array = [int(i) for i in input().split()]
	for j in range(2 if k % 2 == 0 else 3):
		d = max(array)
		array = [d - i for i in array]
	print(*array)


import math
import random

def function1():
	pass

def function2():
	pass
for i in range(int(input())):
	(n, k) = list(map(int, input().split()))
	List = list(map(int, input().split()))
	if k % 2 != 0:
		maximum = max(List)
		List = [maximum - i for i in List]
	else:
		for j in range(2):
			maximum = max(List)
			for i in range(len(List)):
				List[i] = maximum - List[i]
	print(*List)


import math
t = int(input())
while t != 0:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	ma = max(a)
	if k % 2 == 1:
		for i in range(n):
			print(ma - a[i], end=' ')
	else:
		for i in range(n):
			a[i] = ma - a[i]
		ma = max(a)
		for i in range(n):
			print(ma - a[i], end=' ')
	print()
	t -= 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	if n == 1:
		print(0)
	else:
		d = max(arr)
		a = min(arr)
		for i in range(n):
			arr[i] = d - arr[i]
		if (k - 1) % 2 == 0:
			print(*arr)
		else:
			q = d - a
			for j in range(n):
				print(q - arr[j], end=' ')
			print('\n')


def panda(n, k, l):
	(l1, l2) = ([], [])
	d = max(l)
	for i in l:
		l1.append(d - i)
	if k % 2:
		return l1
	d = max(l1)
	for i in l1:
		l2.append(d - i)
	return l2
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	print(*panda(n, k, l))


t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	for _ in range(2):
		mx = max(a)
		a = [mx - x for x in a]
	if k % 2 == 1:
		mx = max(a)
		a = [mx - x for x in a]
	print(*a)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(map(int, input().split()))
	k -= 1
	maxa = max(s)
	for i in range(n):
		s[i] = maxa - s[i]
	maxa = max(s)
	if k % 2:
		for i in range(n):
			print(maxa - s[i], end=' ')
		print()
	else:
		for i in range(n):
			print(s[i], end=' ')
		print()


import sys
from collections import defaultdict as dd
from collections import Counter as cc
from queue import Queue
import math
import itertools
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = lambda : sys.stdin.buffer.readline().rstrip()
for _ in range(int(input())):
	(q, e) = map(int, input().split())
	w = list(map(int, input().split()))
	l = max(w)
	j = min(w)
	if e % 2 == 0:
		for i in range(q):
			w[i] = w[i] - j
		print(*w)
	else:
		for i in range(q):
			w[i] = l - w[i]
		print(*w)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	c_max = max(arr)
	for i in range(len(arr)):
		arr[i] = c_max - arr[i]
	k -= 1
	if k % 2 == 0:
		arr = list(map(str, arr))
		print(' '.join(arr))
	else:
		c_max = max(arr)
		for i in range(len(arr)):
			arr[i] = c_max - arr[i]
		arr = list(map(str, arr))
		print(' '.join(arr))


for i in range(int(input())):
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if a[1] % 2 == 0:
		max_value = max(b)
		list_ = []
		for i in b:
			value = max_value - i
			list_.append(value)
		max_value_2 = max(list_)
		list_2 = []
		for i in list_:
			value = max_value_2 - i
			list_2.append(value)
		print(*list_2, sep=' ')
	else:
		max_value = max(b)
		list_ = []
		for i in b:
			value = max_value - i
			list_.append(value)
		print(*list_, sep=' ')


def operation(a):
	d = max(a)
	for i in range(len(a)):
		a[i] = d - a[i]

def main():
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		a = list(map(int, input().split()))
		operation(a)
		if k % 2 == 0:
			operation(a)
		print(*a)
main()


import sys

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math
from collections import defaultdict
for _ in range(ri()):
	(n, k) = ria()
	l = ria()
	m = max(l)
	for i in range(n):
		l[i] = m - l[i]
	k -= 1
	if k % 2 == 0:
		print(*l)
		continue
	else:
		m = max(l)
		for i in range(n):
			l[i] = m - l[i]
		print(*l)


def do(s, n, k):
	if n == 1:
		print(0)
		return
	if k <= 2:
		for i in range(k):
			kl = max(s)
			s = list(map(lambda x: kl - x, s))
		print(*s)
	else:
		for i in range(1):
			kl = max(s)
			s = list(map(lambda x: kl - x, s))
		kl = max(s)
		p = list(map(lambda x: kl - x, s))
		k -= 2
		if k % 2 == 0:
			print(*p)
		else:
			print(*s)
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(map(int, input().split()))
	do(s, n, k)


t = input()
t = int(t)
for i in range(t):
	(n, k) = input().split(' ')
	n = int(n)
	k = int(k)
	arr = list(map(int, input().rstrip().split()))
	d = max(arr)
	c = []
	cc = []
	for j in range(len(arr)):
		c.append(d - arr[j])
	dd = max(c)
	for k1 in range(len(c)):
		cc.append(dd - c[k1])
	if k % 2 == 0:
		print(*cc)
	else:
		print(*c)


for ii in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	m = max(a)
	for kk in range(n):
		a[kk] = m - a[kk]
	o = a[:]
	m = max(a)
	for kk in range(n):
		a[kk] = m - a[kk]
	e = a
	if k % 2 == 1:
		print(*o)
	else:
		print(*e)


import sys
t = int(input())
i = 0
for line in sys.stdin:
	if i == 0:
		(n, k) = (int(x) for x in line.split())
	else:
		lijst_a = [int(x) for x in line.split()]
		maxi = max(lijst_a)
		mini = min(lijst_a)
		if k % 2 == 1:
			lijst = []
			for a in lijst_a:
				lijst.append(maxi - a)
		else:
			lijst = []
			for a in lijst_a:
				lijst.append(a - mini)
		print(*lijst)
	i = 1 - i


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr1 = [0] * n
	m = max(arr)
	for j in range(n):
		arr1[j] = m - arr[j]
	l = max(arr1)
	for i in range(n):
		arr[i] = l - arr1[i]
	if k % 2 == 0:
		print(*arr)
	else:
		print(*arr1)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	maxi = -9999999999
	mini = 9999999999
	for i in range(n):
		maxi = max(maxi, a[i])
		mini = min(mini, a[i])
	b = []
	for i in range(n):
		b.append(maxi - a[i])
	c = []
	maxi = maxi - mini
	for i in range(n):
		c.append(maxi - b[i])
	if k % 2 == 1:
		for i in range(n):
			print(b[i], end=' ')
	else:
		for i in range(n):
			print(c[i], end=' ')
	print()


t = int(input())
for k in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))[:n]
	mx = max(a)
	for i in range(n):
		a[i] = mx - a[i]
	if m == 1:
		for i in a:
			print(i, end=' ')
	else:
		mx = max(a)
		for i in range(n):
			a[i] = mx - a[i]
		if m % 2 == 0:
			for i in a:
				print(i, end=' ')
		else:
			mx = max(a)
			for i in range(n):
				a[i] = mx - a[i]
				print(a[i], end=' ')
	print()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = [int(x) for x in input().split()]
	maxa = max(arr)
	for i in range(n):
		arr[i] = maxa - arr[i]
	if k % 2 != 0:
		print(*arr)
	else:
		maxa = max(arr)
		for i in range(n):
			arr[i] = maxa - arr[i]
		print(*arr)


import os
import sys
from io import BytesIO, IOBase
import math

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
import os
import sys
from io import BytesIO, IOBase

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for xyz in range(0, int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	m = max(l)
	ans1 = []
	for i in range(0, n):
		ans1.append(m - l[i])
	ans2 = []
	m = max(ans1)
	for i in range(0, n):
		ans2.append(m - ans1[i])
	if k % 2 == 0:
		print(*ans2)
	else:
		print(*ans1)


import math
import sys

def dict_sort(ans):
	ans = sorted(ans.items(), reverse=True, key=lambda kv: kv[1])

def is_prime(n):
	if n == 1:
		return 0
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			return False
	return True

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def alphbates():
	return 'abcdefghijklmnopqrstuvwxyz'

def binary_search(ls, n, flag):
	low = 0
	hi = n - 1
	while low <= hi:
		mid = (low + hi) // 2
		if ls[mid] == flag:
			return mid
		elif ls[mid] > flag:
			hi = mid - 1
		else:
			low = mid + 1
	return -1

def inp():
	ls = list(map(int, input().split()))
	return ls

def mult_inp():
	return map(int, input().split())
t = int(input())
for _i in range(t):
	(n, k) = mult_inp()
	ls = inp()
	mx = max(ls)
	mn = min(ls)
	ans1 = []
	ans2 = []
	if n == 1:
		print(0)
	else:
		for i in ls:
			ans1.append(mx - i)
		j = 0
		for i in ls:
			ans2.append(mx - mn - ans1[j])
			j += 1
		if k % 2 == 1:
			for i in ans1:
				print(i, end=' ')
		else:
			for i in ans2:
				print(i, end=' ')
		print()


from __future__ import division, print_function
from sys import stdin, stdout
import bisect
import math
import heapq
i_m = 9223372036854775807

def inin():
	return int(input())

def stin():
	return input()

def spin():
	return map(int, stin().split())

def lin():
	return list(map(int, stin().split()))

def matrix(n):
	return [list(map(int, input().split())) for i in range(n)]

def count2Dmatrix(i, list):
	return sum((c.count(i) for c in list))

def modinv(n, p):
	return pow(n, p - 2, p)

def GCD(x, y):
	x = abs(x)
	y = abs(y)
	if min(x, y) == 0:
		return max(x, y)
	while y:
		(x, y) = (y, x % y)
	return x

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l
prime = []

def SieveOfEratosthenes(n):
	global prime
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	f = []
	for p in range(2, n):
		if prime[p]:
			f.append(p)
	return f
q = []

def dfs(n, d, v, c):
	global q
	v[n] = 1
	x = d[n]
	q.append(n)
	j = c
	for i in x:
		if i not in v:
			f = dfs(i, d, v, c + 1)
			j = max(j, f)
	return j
for _ in range(inin()):
	(n, k) = spin()
	a = lin()
	d1 = []
	d2 = []
	m = max(a)
	for i in range(n):
		d1.append(m - a[i])
	m = max(d1)
	for i in range(n):
		d2.append(m - d1[i])
	if k % 2 != 0:
		print(*d1)
	else:
		print(*d2)


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	(n, k) = (l[0], l[1])
	a = list(map(int, input().split()))
	d = max(a)
	a1 = list(map(lambda x, y: x - y, [d] * n, a))
	d = max(a1)
	a2 = list(map(lambda x, y: x - y, [d] * n, a1))
	if k == 0:
		for j in a:
			print(j, end=' ')
		print()
	elif k % 2 != 0:
		for j in a1:
			print(j, end=' ')
		print()
	else:
		for j in a2:
			print(j, end=' ')
		print()


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	(mi, mx) = (min(l), max(l))
	l = list(map(lambda x: mx - x, l))
	k -= 1
	if k & 1:
		k = mx - mi
		l = list(map(lambda x: k - x, l))
	print(*l)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	for j in range(2 - k % 2):
		d = max(l)
		for i in range(len(l)):
			l[i] = d - l[i]
	print(*l)


from math import *
from copy import *
from string import *
from random import *
from sys import stdin, stdout
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
import math
import math
import time
from queue import Queue

def seive(n):
	l = [True]
	l = l * (n + 1)
	for i in range(2, int(sqrt(n)) + 1):
		if l[i] == True:
			val = i * i
			while val < len(l):
				l[val] = False
				val += i
	prime = []
	for i in range(2, len(l)):
		if l[i] == True:
			prime.append(i)
	return prime

def dp(l, i, n, val, ans):
	if i >= n or val < 0:
		return 1000000
	elif val == 0:
		return 0
	else:
		if ans[i] == 1000000:
			ans[i] = min(min(1 + dp(l, i + 1, n, val - l[i], ans), 1 + dp(l, i, n, val - l[i], ans)), dp(l, i + 1, n, val, ans))
		return ans[i]
from queue import Queue

def factors(n):
	l = []
	for i in range(1, int(sqrt(n)) + 1):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def check1(s, v, x):
	while True:
		if v not in s:
			return v
		else:
			v -= 1

def check2(s, v, x):
	while True:
		if v not in s:
			return v
		else:
			v += 1

def up(n):
	j = n - 1
	while j > 0:
		if n % j == 0:
			break
		j -= 1
	return j

def fac(n):
	c = 1
	i = 1
	while i <= n:
		c *= i
		i += 1
	return c

def check_happy(n):
	ss = set()
	print(n)
	while n != 1:
		val = n
		s = 0
		print(val)
		while val != 0:
			s += (val % 10) ** 2
			val = val // 10
		print(val)
		print('hi')
		if val in ss:
			return False
		else:
			n = val
			ss.add(n)
	return True

def update(a, b):
	c = 1
	val = a
	while a < b:
		print(c, a)
		c += c
		a += a
	print(1)
	while a > b:
		print()
		a -= val
		c -= 1
	return c
import random as rand

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)
from itertools import permutations

def insertion_sort(arr):
	for i in range(len(arr)):
		j = i
		while j > 0:
			if arr[j] < arr[j - 1]:
				temp = arr[j]
				arr[j] = arr[j - 1]
				arr[j - 1] = temp
			j -= 1
	return arr

def quick_sort(arr, low, high):
	i = low
	j = high
	while i < j:
		if arr[i] > arr[low] and arr[j] < arr[low]:
			temp = arr[i]
			arr[i] = arr[j]
			arr[j] = arr[i]
			i += 1
			j -= 1
		elif arr[i] <= arr[low]:
			i += 1
		elif arr[j] >= arr[low]:
			j -= 1
	print(i, j)
	toto = arr[j]
	arr[j] = arr[low]
	arr[low] = toto
	return j

def dodo(arr, low, high):
	if low < high:
		val = quick_sort(arr, low, high)
		dodo(arr, low, val - 1)
		dodo(arr, val + 1, high)

def dp(arr, c, n, k, z, ans):
	if k == 0:
		return ans
	elif c == 0:
		return dp(arr, c + 1, n, k - 1, z, ans + arr[c + 1])
	elif c == n - 1:
		if z == 0:
			return 0
		else:
			return dp(arr, c - 1, n, k - 1, z - 1, ans + arr[c - 1])
	elif z == 0:
		return dp(arr, c + 1, n, k - 1, z, ans + arr[c + 1])
	else:
		return max(dp(arr, c + 1, n, k - 1, z, ans + arr[c + 1]), dp(arr, c - 1, n, k - 1, z - 1, ans + arr[c - 1]))

def check(arr, val):
	a = -1
	for i in range(len(arr)):
		if arr[i][len(arr[i]) - 1] == val:
			a = i
			break
	return a

def reverse(s, i, ans):
	if i >= len(s):
		return ans
	else:
		return reverse(s, i + 1, s[i] + ans)

def update(arr, i, j, n, m):
	if i >= 0 and i < n and (j >= 0) and (j < m):
		if arr[i][j] == 1:
			arr[i][j] == 2
			return [i, j]
	return [-1, -1]
t = int(stdin.readline())
for i in range(t):
	(n, k) = map(int, stdin.readline().split(' '))
	l = list(map(int, stdin.readline().split(' ')))
	maxa = max(l)
	mini = min(l)
	if maxa == mini:
		ans = [0] * n
		print(*ans)
	else:
		for j in range(n):
			l[j] = maxa - l[j]
		k -= 1
		if k % 2 == 0:
			print(*l)
		else:
			maxa = max(l)
			for j in range(n):
				l[j] = maxa - l[j]
			print(*l)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	l = [int(i) for i in input().split()]
	k -= 1
	m = max(l)
	for i in range(n):
		l[i] = m - l[i]
	m = max(l)
	if k % 2 != 0:
		for i in range(n):
			l[i] = m - l[i]
	for i in l:
		print(i, end=' ')
	print()


import math, sys
from collections import defaultdict, Counter, deque
INF = float('inf')
MOD = 10 ** 9 + 7

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def isPrime(n):
	if n <= 1:
		return False
	i = 2
	while i ** 2 <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def primeFactors(n):
	factors = []
	i = 2
	while i ** 2 <= n:
		while n % i == 0:
			factors.append(i)
			n //= i
		i += 1
	if n > 1:
		factors.append(n)
	return factors

def vars():
	return map(int, input().split())

def array():
	return list(map(int, input().split()))

def a():
	n = int(input())
	arr = set(map(int, input().split()))
	if len(arr) > 1:
		print(1)
	else:
		print(n)

def b():
	(n, k) = vars()
	arr = array()
	k = 1 if k % 2 == 1 else 2
	while k:
		m = max(arr)
		for i in range(n):
			arr[i] = m - arr[i]
		k -= 1
	print(*arr)
t = 1
t = int(input())
for _ in range(t):
	b()


t = int(input())
for _ in range(t):
	(n, p) = map(int, input().split())
	l = list(map(int, input().split()))
	if p % 2 == 0:
		j = max(l)
		for i in range(n):
			l[i] = j - l[i]
		m = max(l)
		for i in range(n):
			l[i] = m - l[i]
	else:
		j = max(l)
		for i in range(n):
			l[i] = j - l[i]
	for i in range(n):
		print(l[i], end=' ')
	print()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	(*a,) = map(int, input().split())
	d = max(a)
	for i in range(n):
		a[i] = d - a[i]
	d2 = max(a)
	a2 = [d2 - ai for ai in a]
	if k % 2:
		print(*a)
	else:
		print(*a2)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if k % 2 == 0:
		for i in range(2):
			m = max(a)
			for j in range(n):
				a[j] = m - a[j]
	else:
		m = max(a)
		for j in range(n):
			a[j] = m - a[j]
	for el in a:
		print(el, end=' ')
	print()


from sys import stdin, stdout
import bisect
import math
from collections import deque
mod = 10 ** 9 + 7

def st():
	return list(stdin.readline().strip())

def inp():
	return int(stdin.readline())

def li():
	return list(map(int, stdin.readline().split()))

def mp():
	return map(int, stdin.readline().split())

def pr(n):
	stdout.write(str(n) + '\n')

def DFS(dictionary, vertex, visited):
	visited[vertex] = True
	stack = [vertex]
	print(vertex)
	while stack:
		a = stack.pop()
		for i in dictionary[a]:
			if not visited[i]:
				print(i)
				visited[i] = True
				stack.append(i)

def BFS(dictionary, vertex, visited):
	visited[vertex] = True
	q = deque()
	q.append(vertex)
	while q:
		a = q.popleft()
		for i in dictionary[a]:
			if not visited[i]:
				visited[i] = True
				q.append(i)
				print(i)

def soe(limit):
	l = [1] * (limit + 1)
	l[0] = 0
	l[1] = 0
	prime = []
	for i in range(2, limit + 1):
		if l[i]:
			for j in range(i * i, limit + 1, i):
				l[j] = 0
	for i in range(2, limit + 1):
		if l[i]:
			prime.append(i)
	return prime

def segsoe(low, high):
	limit = int(high ** 0.5) + 1
	prime = soe(limit)
	n = high - low + 1
	l = [0] * (n + 1)
	for i in range(len(prime)):
		lowlimit = low // prime[i] * prime[i]
		if lowlimit < low:
			lowlimit += prime[i]
		if lowlimit == prime[i]:
			lowlimit += prime[i]
		for j in range(lowlimit, high + 1, prime[i]):
			l[j - low] = 1
	for i in range(low, high + 1):
		if not l[i - low]:
			if i != 1:
				print(i)

def gcd(a, b):
	while b:
		a = a % b
		(b, a) = (a, b)
	return a

def power(a, n):
	r = 1
	while n:
		if n & 1:
			r = r * a
		a *= a
		n = n >> 1
	return r

def solve():
	(n, k) = mp()
	l = li()
	m = max(l)
	ans = []
	anss = []
	for i in range(n):
		ans.append(m - l[i])
	z = max(ans)
	for i in range(n):
		anss.append(z - ans[i])
	if k & 1:
		print(*ans)
	else:
		print(*anss)
for _ in range(inp()):
	solve()


from sys import stdin
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')
(t,) = gil()
for _ in range(t):
	(n, k) = gil()
	arr = gil()
	if k:
		if k & 1:
			maxi = max(arr)
			for i in range(n):
				arr[i] = maxi - arr[i]
		else:
			mini = min(arr)
			for i in range(n):
				arr[i] -= mini
	for a in arr:
		print(a, end=' ')
	print()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = [*map(int, input().split())]
	k = 1 if k % 2 else 2
	for i in range(k):
		d = max(arr)
		arr = [d - arr[j] for j in range(n)]
	print(' '.join(map(str, arr)))


from sys import stdin, stdout, setrecursionlimit

class Tail_Recursion_Optimization:

	def __init__(self, RECURSION_LIMIT, STACK_SIZE):
		setrecursionlimit(RECURSION_LIMIT)
		threading.stack_size(STACK_SIZE)
		return None

class SOLVE:

	def solve(self):
		R = stdin.readline
		W = stdout.write
		ans = []
		for i in range(int(R())):
			(n, k) = map(int, R().split())
			a = [int(x) for x in R().split()]
			mx = max(a)
			a = [mx - a[j] for j in range(n)]
			mx = max(a)
			for j in range(n):
				if k % 2:
					ans.append('{} '.format(a[j]))
				else:
					ans.append('{} '.format(mx - a[j]))
			ans.append('\n')
		W(''.join(ans))
		return 0

def main():
	s = SOLVE()
	s.solve()
main()


T = int(input())
for t in range(T):
	(n, k) = map(int, input().split())
	lista = list(map(int, input().strip().split()))
	max_val = max(lista)
	new_lis_odd = [max_val - val for val in lista]
	max2 = max(new_lis_odd)
	new_lis_even = [max2 - val for val in new_lis_odd]
	if k % 2 == 0:
		for val in new_lis_even[:n - 1]:
			print(val, '', end='')
		print(new_lis_even[n - 1])
	else:
		for val in new_lis_odd[:n - 1]:
			print(val, '', end='')
		print(new_lis_odd[n - 1])


def solve(l, n, k):
	ff = 0
	d = max(l)
	l1 = l.copy()
	for i in range(n):
		l1[i] = d - l1[i]
	d = max(l1)
	l2 = l1.copy()
	for i in range(n):
		l2[i] = d - l2[i]
	if k % 2 == 0:
		for x in l2:
			print(x, end=' ')
		print()
	else:
		for x in l1:
			print(x, end=' ')
		print()
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	solve(l, n, k)


t = int(input())
while t:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	d = max(a)
	for j in range(n):
		a[j] = d - a[j]
	if k % 2 == 0:
		d = max(a)
		for j in range(n):
			a[j] = d - a[j]
	for i in a:
		print(i, end=' ')
	print('\n')
	t -= 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	maxx = max(arr)
	a = arr[:]
	for i in range(n):
		a[i] = maxx - a[i]
	b = a[:]
	m = max(b)
	for i in range(n):
		b[i] = m - b[i]
	if k % 2 == 1:
		print(*a)
	else:
		print(*b)


import sys
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	aodd = []
	aeven = []
	maxx = max(a)
	need = maxx - min(a)
	for i in a:
		aodd.append(maxx - i)
	for i in aodd:
		aeven.append(need - i)
	if k % 2 == 1:
		print(*aodd)
	else:
		print(*aeven)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if k % 2 == 0:
		minval = min(a)
		print(' '.join([str(x - minval) for x in a]))
	else:
		maxval = max(a)
		print(' '.join([str(maxval - x) for x in a]))


import time, math as mt, bisect as bs, sys
from sys import stdin, stdout
from collections import defaultdict
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
pi = 3.141592653589793

def II():
	return int(stdin.readline())

def IO():
	return stdin.readline()

def IP():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

def lcm(a, b):
	return a * b // gcd(a, b)

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def readTree():
	v = int(input())
	adj = [set() for i in range(v + 1)]
	for i in range(v - 1):
		(u1, u2) = In()
		adj[u1].add(u2)
		adj[u2].add(u1)
	return (adj, v)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def sieve():
	li = [True] * 1000001
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	prime = []
	for i in range(1000001):
		if li[i] == True:
			prime.append(i)
	return prime

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count
mx = 10 ** 7
spf = [mx] * (mx + 1)

def SPF():
	spf[1] = 1
	for i in range(2, mx + 1):
		if spf[i] == mx:
			spf[i] = i
			for j in range(i * i, mx + 1, i):
				if i < spf[j]:
					spf[j] = i
	return
mod = 10 ** 9 + 7

def solve():
	(n, k) = IP()
	li = L()
	d = max(li)
	for i in range(n):
		li[i] = d - li[i]
	k -= 1
	mx = max(li)
	if k % 2 == 0:
		print(*li)
	else:
		for ele in li:
			print(mx - ele, end=' ')
		print()
	return
t = II()
for i in range(t):
	solve()


def ans(n, arr, k):
	d = max(arr)
	if k % 2 == 0:
		k = 2
	else:
		k = 1
	for i in range(k):
		temp = -float('inf')
		for j in range(n):
			arr[j] = d - arr[j]
			temp = max(temp, arr[j])
		d = temp
	return arr
T = int(input())
for i in range(T):
	(n, k) = map(int, input().strip().split(' '))
	arr = list(map(int, input().strip().split(' ')))
	res = ans(n, arr, k)
	fin = ''
	for i in res:
		fin += str(i) + ' '
	print(fin.strip())


from __future__ import division, print_function
import os, sys
import math
import collections
from itertools import permutations
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

class my_dictionary(dict):

	def __init__(self):
		self = dict()

	def add(self, key, value):
		self[key] = value

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[1]

def sort2(l):
	return sorted(l, key=getKey, reverse=True)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(n - r))

def binary_search(arr, low, high, x):
	if high >= low:
		mid = (high + low) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] > x:
			return binary_search(arr, low, mid - 1, x)
		else:
			return binary_search(arr, mid + 1, high, x)
	else:
		return -1

def ceil(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def padded_bin_with_complement(x):
	if x < 0:
		return bin(2 ** 16 - abs(x))[2:].zfill(16)
	else:
		return bin(x)[2:].zfill(16)

def binaryToDecimal(binary):
	binary1 = binary
	(decimal, i, n) = (0, 0, 0)
	while binary != 0:
		dec = binary % 10
		decimal = decimal + dec * pow(2, i)
		binary = binary // 10
		i += 1
	print(decimal)

def CountFrequency(my_list):
	freq = {}
	for item in my_list:
		if item in freq:
			freq[item] += 1
		else:
			freq[item] = 1
	return freq

def pos(a):
	b = [0] * len(a)
	c = sorted(a)
	for i in range(len(a)):
		for j in range(len(a)):
			if c[j] == a[i]:
				b[i] = j
				break
	return b

def smallestDivisor(n):
	if n % 2 == 0:
		return 2
	i = 3
	while i * i <= n:
		if n % i == 0:
			return i
		i += 2
	return n

def commonn(a, b, n):
	c = []
	for i in range(n):
		if a[i] == b[i]:
			c.append('-1')
		else:
			c.append(b[i])
	return c

def primeFactors(n):
	j = []
	while n % 2 == 0:
		j.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			j.append(int(n))
			n = n / i
	if n > 2:
		j.append(int(n))
	return j

def sumdigit(n):
	n = str(n)
	k = 0
	for i in range(len(n)):
		k += int(n[i])
	return k

def question(a, n):
	j = a
	for i in range(n):
		if a[i] == '1':
			j[i] = '0'
		else:
			j[i] = '1'
	j[0, n - 1].reverse()
	return j

def main():
	for _ in range(ii()):
		(n, k) = mi()
		a = li()
		d = max(a)
		b1 = [0] * n
		b2 = [0] * n
		j = math.floor(k / n)
		for i in range(n):
			b1[i] = d - a[i]
		d = max(b1)
		for i in range(n):
			b2[i] = d - b1[i]
		if k % 2:
			print(*b1)
		else:
			print(*b2)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for i in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	if k % 2 == 0:
		maxo = max(a)
		for i in range(n):
			a[i] = maxo - a[i]
		maxo = max(a)
		for i in range(n):
			a[i] = maxo - a[i]
		print(*a)
	else:
		maxo = max(a)
		for i in range(n):
			a[i] = maxo - a[i]
		print(*a)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if k % 2:
		m = max(a)
		for i in a:
			print(m - i, end=' ')
	else:
		m = min(a)
		for i in a:
			print(i - m, end=' ')
	print()


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	res = []
	if k % 2 == 0:
		mx = min(l)
		for j in range(n):
			res.append(l[j] - mx)
		print(*res)
	else:
		mx = max(l)
		for j in range(n):
			res.append(mx - l[j])
		print(*res)


n = int(input())
for _ in range(n):
	(m, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	d = max(a)
	a1 = [d - x for x in a]
	d = max(a1)
	a2 = [d - x for x in a1]
	if k % 2 == 0:
		for i in a2:
			print(i, end=' ')
	else:
		for i in a1:
			print(i, end=' ')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = []
	t1 = max(a)
	t2 = min(a)
	t3 = t1 - t2
	if k % 2 != 0:
		for i in range(n):
			b.append(t1 - a[i])
	else:
		for i in range(n):
			b.append(t3 - (t1 - a[i]))
	print(*b)


t = int(input())
while t:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	m = max(a)
	p = m - min(a)
	b = [m - i for i in a]
	c = [p - i for i in b]
	if k % 2:
		print(*b)
	else:
		print(*c)
	t = t - 1


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	mq = max(l)
	for j in range(len(l)):
		l[j] = mq - l[j]
	k = k - 1
	if k == 0:
		print(*l)
	elif k % 2 == 0:
		print(*l)
	else:
		k % 2 == 1
		mq = max(l)
		for j in range(len(l)):
			l[j] = mq - l[j]
		print(*l)


l = []
for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	mn = min(a)
	mx = max(a)
	s = str()
	if k % 2 == 1:
		for i in a:
			s = s + f'{mx - i} '
	else:
		for i in a:
			s = s + f'{i - mn} '
	l.append(s)
for i in l:
	print(i)


def solve(n, k, ar):
	d = max(ar)
	for i in range(n):
		ar[i] = d - ar[i]
	k -= 1
	ar2 = []
	d = max(ar)
	for i in range(n):
		ar2.append(d - ar[i])
	if k % 2 == 0:
		print(' '.join(map(str, ar)))
	else:
		print(' '.join(map(str, ar2)))
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	ar = list(map(int, input().split()))
	solve(n, k, ar)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	d = max(a)
	if k == 1:
		for j in a:
			print(d - j, end=' ')
	elif n == 1:
		print(0)
	else:
		l = []
		for j in a:
			l.append(d - j)
		e = max(l)
		if (k - 1) % 2 == 0:
			for j in l:
				print(j, end=' ')
		else:
			for j in l:
				print(e - j, end=' ')
	print()


tests = int(input())
for t in range(tests):
	k = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	m = max(a)
	reduced = [m - x for x in a]
	if k[1] % 2 != 0:
		print(' '.join(list(map(str, reduced))))
	else:
		m = max(reduced)
		b = [m - x for x in reduced]
		print(' '.join(list(map(str, b))))


import sys
from math import sqrt
from collections import OrderedDict
inpt = sys.stdin.readline

def inp():
	return int(inpt())

def inlist():
	return list(map(int, inpt().split()))

def instr():
	s = inpt()
	return list(s[:len(s) - 1])

def invr():
	return map(int, inpt().split())

class node(object):

	def __init__(self, x, p, h):
		(self.x, self.p, self.h) = (x, p, h)
		self.children = []

	def add_child(self, obj):
		self.children.append(obj)

def main():
	t = inp()
	for l in range(t):
		(n, k) = invr()
		a = inlist()
		mx = max(a)
		mn = mx - min(a)
		a1 = a.copy()
		for i in range(n):
			a1[i] = mx - a1[i]
		a2 = a1.copy()
		for i in range(n):
			a2[i] = mn - a2[i]
		if k % 2 == 0:
			for i in range(n):
				print(a2[i], end=' ')
			print()
		else:
			for i in range(n):
				print(a1[i], end=' ')
			print()
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	a = min(l)
	e = max(l)
	if k % 2 == 0:
		for i in range(n):
			l[i] -= a
	else:
		for i in range(n):
			l[i] = e - l[i]
	print(*l)


def infi(arr):
	mx = max(arr)
	output = []
	for i in arr:
		output.append(mx - i)
	return output

def test_case():
	(N, K) = input_int_list()
	arr = input_int_list()
	if K != 0:
		arr = infi(arr)
		if K % 2 == 0:
			arr = infi(arr)
	print(*arr)

def input_int_list():
	return [int(x) for x in input().split()]
t = int(input())
for x in range(t):
	test_case()


for x in range(int(input())):
	(n, k) = input().split()
	n = int(n)
	k = int(k) % 2
	lst = [int(i) for i in input().split()]
	h = max(lst)
	l = min(lst)
	if k == 1:
		for i in lst:
			print(h - i, end=' ')
	else:
		for i in lst:
			print(i - l, end=' ')
	print()


t = int(input().strip(' '))
for _ in range(t):
	(n, q) = map(int, input().strip(' ').split(' '))
	arr = list(map(int, input().strip(' ').split(' ')))
	if q == 0:
		print(' '.join((str(x) for x in arr)))
		continue
	x = sorted(arr)
	(m1, m2) = (x[0], x[-1])
	if q % 2:
		for i in range(n):
			arr[i] = m2 - arr[i]
	else:
		for i in range(n):
			arr[i] = arr[i] - m1
	print(' '.join((str(x) for x in arr)))


t = int(input())
while t:
	(n, k) = map(int, input().split())
	nums = list(map(int, input().split()))
	mini = min(nums)
	maxi = max(nums)
	for i in range(n):
		nums[i] = maxi - nums[i]
	k -= 1
	if k % 2:
		maxi -= mini
		for i in range(n):
			if i == n - 1:
				print(maxi - nums[i])
			else:
				print(maxi - nums[i], end=' ')
	else:
		for i in range(n):
			if i == n - 1:
				print(nums[i])
			else:
				print(nums[i], end=' ')
	t -= 1


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	m2 = max(l)
	if k == 0:
		print(*l)
		continue
	ans = 1 if k % 2 != 0 else 2
	for i in range(ans):
		m = m2
		m2 = 0
		for j in range(n):
			l[j] = m - l[j]
			m2 = max(m2, l[j])
	print(*l)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	ma = max(a)
	mi = ma - min(a)
	for x in range(n):
		a[x] = ma - a[x]
	if k % 2 == 0:
		for x in range(n):
			a[x] = mi - a[x]
	for x in range(n):
		print(a[x], end=' ')
	print()


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b / gcd(a, b)

def read(func=int):
	return map(func, input().split())
t = int(input())
while t:
	(n, k) = read()
	nums = list(read())
	mx = max(nums)
	for i in range(n):
		nums[i] = mx - nums[i]
	if (k - 1) % 2 == 1:
		mx = max(nums)
		for i in range(n):
			nums[i] = mx - nums[i]
	print(*nums, sep=' ')
	t -= 1


def function(n, k, array):
	for i in range(k):
		d = max(array)
		for j in range(n):
			array[j] = d - array[j]
	return array
for _ in range(int(input())):
	(n1, k1) = [int(x) for x in input().split()]
	array1 = [int(x) for x in input().split()]
	k1 = k1 % 2
	if not k1:
		k1 += 2
	print(*function(n1, k1, array1))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	d = max(a)
	for j in range(n):
		a[j] = d - a[j]
	if k % 2 != 0:
		for x in a:
			print(x, end=' ')
		continue
	e = max(a)
	for k in range(n):
		a[k] = e - a[k]
	for x in a:
		print(x, end=' ')


n = int(input())
for i in range(n):
	(t, k) = [int(t) for t in input().split()]
	arr = [int(item) for item in input().split()]
	maxi = -10 ** 9 - 1
	mini = 10 ** 9 + 1
	for j in arr:
		if maxi < j:
			maxi = j
		if mini > j:
			mini = j
	for i in range(t):
		arr[i] = maxi - arr[i]
	if k % 2 != 0:
		print(*arr)
	else:
		r = maxi - mini
		for i in range(t):
			arr[i] = r - arr[i]
		print(*arr)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
from bisect import bisect_left
from collections import defaultdict

def solve():
	t = int(input())
	for _ in range(t):
		(n, k) = sep()
		ar = lis()
		if k % 2 == 1:
			m = max(ar)
			for i in range(n):
				ar[i] = m - ar[i]
		else:
			m = min(ar)
			for i in range(n):
				ar[i] = ar[i] - m
		for i in ar:
			print(i, end=' ')
		print()
solve()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = [int(i) for i in input().split()]
	a = [0] * len(l)
	y = max(l)
	for i in range(len(l)):
		a[i] = y - l[i]
	b = [0] * len(a)
	yy = max(a)
	for j in range(len(a)):
		b[j] = yy - a[j]
	if k % 2 == 0:
		print(*b)
	else:
		print(*a)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	b = list(map(int, input().split()))
	m = max(b)
	r = m - min(b)
	c = []
	for j in range(n):
		c.append([b[j], j])
	c.sort()
	d = []
	for j in range(n):
		d.append([m - c[j][0], c[j][1]])
	e = []
	for j in range(n):
		e.append([r - d[j][0], d[j][1]])
	ans = [0] * n
	if k % 2 != 0:
		for j in range(n):
			ans[d[j][1]] = d[j][0]
	else:
		for j in range(n):
			ans[e[j][1]] = e[j][0]
	print(*ans)


t = int(input())
for o in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	x = []
	y = []
	d = max(a)
	for i in range(n):
		x.append(d - a[i])
	d = max(x)
	for i in range(n):
		y.append(d - x[i])
	if k % 2 == 0:
		print(*y, sep=' ')
	else:
		print(*x, sep=' ')


for _ in range(0, int(input())):
	(n, k) = map(int, input().split())
	list1 = list(map(int, input().strip().split()))[:n]
	max1 = max(list1)
	for i in range(0, len(list1)):
		list1[i] = max1 - list1[i]
	list2 = list1[:]
	max2 = max(list2)
	for i in range(0, len(list2)):
		list2[i] = max2 - list2[i]
	if k == 1:
		print(*list1)
	elif k == 2:
		print(*list2)
	elif k % 2 != 0:
		print(*list1)
	elif k % 2 == 0:
		print(*list2)


def operation(l):
	d = max(l)
	return [d - i for i in l]
for _ in range(int(input())):
	(n, k) = (int(i) for i in input().split())
	a = [int(i) for i in input().split()]
	if k % 2 == 0:
		print(*operation(operation(a)))
	else:
		print(*operation(a))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	lis = list(map(int, input().split()))
	m = max(lis)
	ch_1 = []
	ch_2 = []
	for i in range(n):
		lis[i] = m - lis[i]
		ch_1.append(lis[i])
	m = max(lis)
	for i in range(n):
		lis[i] = m - lis[i]
		ch_2.append(lis[i])
	if k % 2 == 0:
		print(*ch_2)
	else:
		print(*ch_1)


T = int(input())
for t in range(T):
	(n, k) = input().split(' ')
	k = int(k)
	q = input().split(' ')
	q = [int(x) for x in q]
	m = max(q)
	q2 = []
	for i in q:
		q2 += [m - i]
	if k % 2 == 1:
		q2 = [str(x) for x in q2]
		print(' '.join(q2))
	else:
		m = max(q2)
		q = []
		for i in q2:
			q += [m - i]
		q = [str(x) for x in q]
		print(' '.join(q))


n = int(input())
for i in range(0, n):
	(n1, m) = map(int, input().split())
	l = list(map(int, input().split()))
	if n1 == 1:
		print(0)
	elif n1 == 2 and m == 1:
		m = max(l[0], l[1])
		l[0] = m - l[0]
		l[1] = m - l[1]
		print(l[0], l[1])
	elif m == 0:
		for p in range(0, n1):
			print(l[p], end=' ')
	else:
		m1 = max(l)
		for k in range(0, n1):
			l[k] = m1 - l[k]
		if m % 2 == 1:
			for p in range(0, n1):
				print(l[p], end=' ')
		else:
			m1 = max(l)
			for k in range(0, n1):
				l[k] = m1 - l[k]
			for p in range(0, n1):
				print(l[p], end=' ')


t = int(input())
for it in range(t):
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	mn = min(a)
	mx = max(a)
	add = 0
	sgn = 1 if k % 2 == 0 else -1
	add = -mn if k % 2 == 0 else mx
	print(*[sgn * i + add for i in a])


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def gift():
	for _ in range(t):
		(n, k) = list(map(int, input().split()))
		arry = list(map(int, input().split()))
		if k % 2:
			maxn = max(arry)
			yield ' '.join((str(x) for x in map(lambda x: maxn - x, arry)))
		else:
			minn = min(arry)
			yield ' '.join((str(x) for x in map(lambda x: x - minn, arry)))
t = int(input())
ans = gift()
print(*ans, sep='\n')


b = input()
for _ in range(int(b)):
	d = input().split(' ')
	c = input().split(' ')
	list1 = [int(i) for i in c]
	if int(d[0]) == 1:
		print(0)
	else:
		tag = int(d[1])
		list2 = []
		buffer = max(list1)
		for i in list1:
			list2.append(buffer - i)
		list3 = []
		buffer = max(list2)
		for i in list2:
			list3.append(buffer - i)
		if tag % 2 == 0:
			for i in range(len(list3)):
				if i != len(list3) - 1:
					print(list3[i], end=' ')
				else:
					print(list3[i])
		else:
			for i in range(len(list2)):
				if i != len(list2) - 1:
					print(list2[i], end=' ')
				else:
					print(list2[i])


import sys
import math
from collections import defaultdict, Counter
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	m = max(a)
	m1 = -10 ** 9
	for j in range(n):
		a[j] = m - a[j]
		m1 = max(a[j], m1)
	if k & 1:
		print(*a)
	else:
		for j in range(n):
			a[j] = m1 - a[j]
		print(*a)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	m = max(l)
	l[:] = [m - number for number in l]
	if k % 2 != 0:
		print(*l)
	else:
		m = max(l)
		l[:] = [m - number for number in l]
		print(*l)


t = int(input())
while t != 0:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))[:n]
	x = max(a)
	y = min(a)
	if k % 2 != 0:
		for i in range(n):
			a[i] = x - a[i]
	else:
		for i in range(n):
			a[i] = a[i] - y
	print(*a)
	t -= 1


from sys import stdin
for i in range(int(input())):
	(n, k) = map(int, stdin.readline().rstrip().split(' '))
	l = list(map(int, stdin.readline().rstrip().split(' ')))
	mi = min(l)
	ma = max(l)
	new_ma = ma - mi
	if n == 1:
		print(0)
	else:
		if k == 1:
			for i in range(n):
				print(ma - l[i], end=' ')
		elif k > 1:
			k = k - 2
			if not k % 2:
				for i in range(n):
					print(new_ma - ma + l[i], end=' ')
			else:
				for i in range(n):
					print(new_ma - new_ma + ma - l[i], end=' ')
		print()


def solve(n, k, a):
	m = max(a)
	for i in range(n):
		a[i] = m - a[i]
	k = (k - 1) % 2
	if k == 1:
		m = max(a)
		for i in range(n):
			a[i] = m - a[i]
	return a
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	print(' '.join(map(str, solve(n, k, a))))


t = int(input())
anss = []
for _ in range(t):
	(n, k) = map(int, input().split(sep=' '))
	l = list(map(int, input().split(sep=' ')))
	k -= 1
	m = max(l)
	for i in range(len(l)):
		l[i] = m - l[i]
	if k % 2 == 0:
		anss.append(l)
	else:
		m = max(l)
		for i in range(len(l)):
			l[i] = m - l[i]
		anss.append(l)
for ans in anss:
	for j in ans:
		print(j, end=' ')
	print()


import math
import os
import random
import re
import sys
from collections import defaultdict, Counter, deque
import heapq
from functools import lru_cache
from itertools import accumulate, chain, combinations, permutations, groupby, zip_longest
from math import floor, ceil, sqrt

def solve(arr, k):
	mx = max(arr)
	arr = [mx - v for v in arr]
	k -= 1
	if k % 2 == 0:
		return arr
	else:
		mx = max(arr)
		return [mx - v for v in arr]
t = int(input())
results = []
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	results += (solve(arr, k),)
for res in results:
	print(' '.join(map(str, res)))


def main():
	n = int(input())
	for i in range(n):
		solve()

def solve():
	(n, k) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	if len(set(arr)) == 1:
		print(*[0 for i in range(n)])
		return
	elif k == 1:
		high = max(arr)
		print(*[high - x for x in arr])
		return
	for i in range(2):
		high = max(arr)
		arr = [high - x for x in arr]
	k -= 2
	if k % 2 == 0:
		print(*arr)
	else:
		print(*[high - x for x in arr])
main()


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
from decimal import *
BUFSIZE = 8192
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	t = int(input())
	for i in range(t):
		(n, k) = map(int, input().split())
		a = list(map(int, input().split()))
		(mx, mn) = (max(a), min(a))
		for j in range(len(a)):
			a[j] = mx - a[j]
		ans1 = a[:]
		(mx, mn) = (max(a), min(a))
		for j in range(len(a)):
			a[j] = mx - a[j]
		ans2 = a[:]
		if k % 2 == 1:
			print(' '.join([str(x) for x in ans1]))
		else:
			print(' '.join([str(x) for x in ans2]))
main()


cases = int(input())
for t in range(cases):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	ma = max(a)
	a1 = [ma - i for i in a]
	mv = max(a1)
	a2 = [mv - i for i in a1]
	if k == 0:
		print(*a)
	elif k % 2 == 0:
		print(*a2)
	else:
		print(*a1)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	(mi, ma) = (min(a), max(a))
	if k % 2 == 0:
		for i in range(n):
			if a[i] == ma:
				print(ma - mi, end=' ')
			elif a[i] == mi:
				print(0, end=' ')
			else:
				print(-mi + a[i], end=' ')
	else:
		for i in range(n):
			if a[i] == ma:
				print(0, end=' ')
			elif a[i] == mi:
				print(ma - mi, end=' ')
			else:
				print(ma - a[i], end=' ')
	print()


for case in range(int(input())):
	(n, k) = map(int, input().split())
	arr = [i for i in map(int, input().split())]
	maximo = max(arr)
	minimo = min(arr)
	if k % 2 == 1:
		arr = [maximo - i for i in arr]
	else:
		arr = [i - minimo for i in arr]
	for i in arr:
		print(int(i), end=' ')


import sys
input = sys.stdin.readline

def op(ls, p):
	if p % 2 == 1:
		mx = max(ls)
		for (idx, val) in enumerate(ls):
			ls[idx] = mx - val
	else:
		mx = min(ls)
		for (idx, val) in enumerate(ls):
			ls[idx] = val - mx

def solve():
	(n, k) = map(int, input().split())
	ls = list(map(int, input().split()))
	op(ls, k)
	print(*ls)
T = int(input())
for _ in range(T):
	solve()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split(' '))
	a = [int(x) for x in input().split(' ')[:n]]
	amax = max(a)
	if k % 2 == 0:
		amax = max(a)
		for i in range(len(a)):
			a[i] = amax - a[i]
		amax = max(a)
		for i in range(len(a)):
			a[i] = amax - a[i]
	else:
		for i in range(len(a)):
			a[i] = amax - a[i]
	print(*a)


t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	a = max(arr)
	for j in range(n):
		arr[j] = a - arr[j]
	ans1 = []
	for j in range(n):
		ans1.append(arr[j])
	b = max(arr)
	for j in range(n):
		arr[j] = b - arr[j]
	ans2 = []
	for j in range(n):
		ans2.append(arr[j])
	if k % 2 == 0:
		print(' '.join((str(x) for x in ans2)))
	else:
		print(' '.join((str(x) for x in ans1)))


for t in range(int(input())):
	(n, k) = list(map(int, input().split()))
	integers = list(map(int, input().split()))
	sorted_integers = sorted(integers)
	if k % 2 != 0:
		maximum = sorted_integers[-1]
		for i in range(0, n):
			integers[i] = maximum - integers[i]
	else:
		maximum = sorted_integers[0]
		for i in range(n):
			integers[i] = integers[i] - maximum
	print(*integers)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a1 = list(a)
	d = max(a1)
	for i in range(n):
		a1[i] = d - a1[i]
	a2 = list(a1)
	d = max(a2)
	for i in range(n):
		a2[i] = d - a2[i]
	if k % 2 == 1:
		print(*a1)
	else:
		print(*a2)


def do_operation(arr):
	maxs = max(arr)
	return [maxs - x for x in arr]
for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	arrs = [int(x) for x in input().split()]
	arrs = do_operation(arrs)
	if not k % 2:
		arrs = do_operation(arrs)
	print(*arrs)


def main():
	t = int(input())
	for _ in range(t):
		(n, p) = map(int, input().split())
		a = list(map(int, input().split()))
		k = max(a)
		for (idx, i) in enumerate(a):
			a[idx] = k - i
		state1 = a[:]
		k = max(a)
		for (idx, i) in enumerate(a):
			a[idx] = k - i
		state2 = a[:]
		if p % 2:
			print(*state1)
		else:
			print(*state2)
	return
main()


from collections import defaultdict

def ii():
	return int(input())

def si():
	return input()

def li():
	return list(map(int, input().split()))

def mi():
	return map(int, input().split())
t = ii()
for _ in range(t):
	(n, k) = mi()
	l = li()
	f = []
	s = []
	mx = max(l)
	for i in range(n):
		f.append(mx - l[i])
	mx = max(f)
	for i in range(n):
		s.append(mx - f[i])
	if k % 2 == 0:
		print(*s)
	else:
		print(*f)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	ls = list(map(int, input().split()))
	if k % 2 == 0:
		k = 2
	else:
		k = 1
	for i in range(k):
		d = max(ls)
		for i in range(n):
			ls[i] = d - ls[i]
	for i in ls:
		print(i, end=' ')
	print()


t = int(input())
for q in range(t):
	ch = input()
	L = [int(i) for i in ch.split()]
	(n, k) = (L[0], L[1])
	ch = input()
	L = [int(i) for i in ch.split()]
	for j in range(2 + k % 2):
		d = max(L)
		for i in range(n):
			L[i] = d - L[i]
	ch = ''
	for i in L:
		ch += str(i) + ' '
	print(ch)


N = int(input())
for _ in range(N):
	(M, K) = map(int, input().split())
	R = list(map(int, input().split()))
	A = sorted(R)
	if K % 2 == 0:
		Y = [i - A[0] for i in R]
	else:
		Y = [A[-1] - i for i in R]
	print(' '.join((str(i) for i in Y)))


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a_max = float('-inf')
	a_min = float('inf')
	for i in range(n):
		if a[i] > a_max:
			a_max = a[i]
		if a[i] < a_min:
			a_min = a[i]
	for k in range(n):
		a[k] = a_max - a[k]
	if x % 2 == 0:
		for k in range(n):
			a[k] = a_max - a_min - a[k]
	print(*a)


import sys
import math
from math import *
from collections import Counter, defaultdict

def main():
	(n, k) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	for i in range(1):
		m = max(arr)
		for j in range(n):
			arr[j] = m - arr[j]
	for i in range((k - 1) % 2):
		m = max(arr)
		for j in range(n):
			arr[j] = m - arr[j]
	print(*arr)
for i in range(int(input())):
	main()


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if len(a) == 1:
		print('0')
	elif k % 2 != 0:
		a1 = []
		m = max(a)
		for k in range(0, n):
			a1.append(m - a[k])
		print(*a1)
	else:
		a1 = []
		m = max(a)
		for i in range(0, n):
			a1.append(m - a[i])
		a2 = []
		m1 = max(a1)
		for j in range(0, n):
			a2.append(m1 - a1[j])
		print(*a2)


for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	lst = [int(i) for i in input().split()]
	nk = 0
	while k > 0:
		nn = 0
		nz = 0
		max1 = 0
		for i in lst:
			if i < 0:
				nn += 1
			elif i == 0:
				nz += 1
		if nn == 0 and nz > 0 and (k % 2 == 0):
			nk = 1
			break
		max1 = max(lst)
		for i in range(0, n):
			lst[i] = max1 - lst[i]
		k -= 1
	print(*lst)


from sys import stdin, gettrace
if gettrace():
	inputi = input
else:

	def input():
		return next(stdin)[:-1]

	def inputi():
		return stdin.buffer.readline()

def solve():
	(n, k) = map(int, inputi().split())
	aa = [int(a) for a in inputi().split()]
	d = max(aa)
	aa = [d - a for a in aa]
	if k % 2 == 1:
		print(' '.join(map(str, aa)))
	else:
		d = max(aa)
		aa = [d - a for a in aa]
		print(' '.join(map(str, aa)))

def main():
	t = int(inputi())
	for _ in range(t):
		solve()
main()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = [0] * n
	mx = max(a)
	for i in range(n):
		a[i] = mx - a[i]
	mx = max(a)
	for i in range(n):
		b[i] = mx - a[i]
	if k & 1 == 1:
		print(*a)
	else:
		print(*b)


def operation(arr):
	m = max(arr)
	for i in range(len(arr)):
		arr[i] = m - arr[i]
	return arr

def main():
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr_one = operation(arr)
	if k % 2:
		print(*arr_one)
	else:
		print(*operation(arr_one))
for _ in range(int(input())):
	main()


t = int(input())
for q in range(t):
	(n, k) = map(int, input().split())
	if k % 2 == 0:
		k = 2
	else:
		k = 1
	arr = list(map(int, input().split()))
	d = 0
	for i in range(k):
		d = max(arr)
		for i in range(n):
			arr[i] = d - arr[i]
	for i in arr:
		print(i, end=' ')
	print()


import sys
for i in range(0, int(sys.stdin.readline())):
	nk = list(map(int, sys.stdin.readline().split()))
	vl = list(map(int, sys.stdin.readline().split()))
	m = max(vl)
	vl = [m - i for i in vl]
	if nk[1] % 2 == 0:
		m = max(vl)
		vl = [m - i for i in vl]
	sys.stdout.write(' '.join(list(map(str, vl))) + '\n')


import sys
import math

def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return map(int, sys.stdin.readline().split())

def SI():
	return sys.stdin.readline().strip()
t = II()
for q in range(t):
	(n, k) = MI()
	a = LI()
	d = max(a)
	x = [0] * n
	for i in range(n):
		x[i] = d - a[i]
	k -= 1
	if k == 0:
		print(*x)
		continue
	y = [0] * n
	d = max(x)
	for i in range(n):
		y[i] = d - x[i]
	k -= 1
	if k % 2 == 0:
		print(*y)
	else:
		print(*x)


a = int(input())
for i in range(a):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	ans = [0] * len(arr)
	brr = []
	m = max(arr)
	for i in arr:
		brr.append(m - i)
	crr = []
	m = max(brr)
	for i in brr:
		crr.append(m - i)
	if k % 2 == 1:
		print(' '.join(map(str, brr)))
	else:
		print(' '.join(map(str, crr)))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	M = max(arr)
	m = min(arr)
	x = M - m
	if k == 0:
		print(*arr)
	elif k % 2 == 1:
		for i in range(n):
			print(M - arr[i], end=' ')
		print()
	elif k % 2 == 0:
		for i in range(n):
			print(arr[i] - m, end=' ')
		print()


t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	ls = list(map(int, input().split()))
	if k % 2 != 0:
		d = max(ls)
		for i in range(len(ls)):
			ls[i] = d - ls[i]
	else:
		d = max(ls)
		for i in range(len(ls)):
			ls[i] = d - ls[i]
		d = max(ls)
		for i in range(len(ls)):
			ls[i] = d - ls[i]
	print(*ls)


from sys import stdin, stdout
from collections import Counter, OrderedDict
import math
cin = stdin.readline
cout = stdout.write
mp = lambda : list(map(int, cin().split()))

def chars():
	s = cin()
	return list(s[:len(s) - 1])

def pl(a):
	for val in a:
		cout(str(val) + ' ')
	cout('\n')
(t,) = mp()
for _ in range(t):
	(n, k) = mp()
	l = [[] for _ in range(3)]
	l[0] = mp()
	for i in range(1, 3):
		maxi = max(l[i - 1])
		for j in range(n):
			l[i] += [maxi - l[i - 1][j]]
	if k % 2:
		pl(l[1])
	else:
		pl(l[2])


ttt = int(input())
for i in range(ttt):
	(nnn, kkk) = map(int, input().split())
	lll = [int(i) for i in input().split()]
	aaa = max(lll)
	for i in range(len(lll)):
		lll[i] = aaa - lll[i]
	if kkk % 2 == 1:
		print(*lll)
	else:
		aaa = max(lll)
		for i in range(len(lll)):
			lll[i] = aaa - lll[i]
		print(*lll)


import sys
input = sys.stdin.readline
ins = lambda : input().rstrip()
ini = lambda : int(input().rstrip())
inm = lambda : map(int, input().split())
inl = lambda : list(map(int, input().split()))
ans = []
t = ini()
for _ in range(t):
	(n, k) = inm()
	a = inl()
	k = 1 if k % 2 else 2
	for i in range(k):
		d = max(a)
		for i in range(n):
			a[i] = d - a[i]
	ans.append(a)
for i in ans:
	print(*i)


t = int(input())
for z in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	maxele = max(arr)
	minele = min(arr)
	if k % 2 == 0:
		for i in range(n):
			arr[i] = arr[i] - minele
	else:
		for i in range(n):
			arr[i] = maxele - arr[i]
	print(*arr)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	num = list(map(int, input().split()))
	mx = max(num)
	for i in range(len(num)):
		num[i] = mx - num[i]
	mx = max(num)
	if k % 2 == 0:
		for i in range(len(num)):
			num[i] = mx - num[i]
	print(*num)


from sys import stdin, stdout
import math, queue, heapq
fastinput = stdin.readline
fastout = stdout.write
t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	maxx = max(a)
	k -= 1
	for i in range(n):
		a[i] = maxx - a[i]
	maxx = max(a)
	if k % 2 == 0:
		print(*a)
	else:
		for i in a:
			print(maxx - i, end=' ')
		print()


R = lambda : map(int, input().split())
(t,) = R()
for _ in [0] * t:
	(n, k) = R()
	a = (*R(),)
	m = max(a)
	a = [m - x for x in a]
	m = max(a)
	print(*((m - x, x)[k % 2] for x in a))


for i in range(int(input())):
	(n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	if m % 2 == 0:
		e = min(A)
		for i in range(len(A)):
			A[i] -= e
	else:
		e = max(A)
		for i in range(len(A)):
			A[i] = e - A[i]
	print(*A)


def f(a):
	m = max(a)
	for i in range(len(a)):
		a[i] = m - a[i]

def main():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	k %= 2
	if k == 0:
		k = 2
	for _ in range(k):
		f(a)
	print(' '.join(map(str, a)))
t = int(input())
for _ in range(t):
	main()


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	lis = list(map(int, input().split()))
	odd = []
	maxo = max(lis)
	for j in range(len(lis)):
		odd.append(maxo - lis[j])
	even = []
	maxo = max(odd)
	for j in range(len(odd)):
		even.append(maxo - odd[j])
	if k % 2 == 0:
		print(*even)
	else:
		print(*odd)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	if k >= 5:
		k = 5 + (k - 5) % 2
	for i in range(k):
		temp = max(arr)
		for j in range(n):
			x = arr[j]
			arr[j] = temp - x
	print(*arr, sep=' ')


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if k > 1:
		k = 2 + k % 2
	while k > 0:
		mx = max(a)
		a = [int(mx - a[i]) for i in range(n)]
		k -= 1
	print(*a)


import sys, math, cmath, time
start_time = time.time()

def solve():
	(n, k) = invr()
	a = inlt()
	q = max(a)
	w = [q - a[i] for i in range(len(a))]
	qq = max(w)
	qw = [qq - w[i] for i in range(len(w))]
	if k % 2 == 0:
		print(*qw)
	else:
		print(*w)

def main():
	global tt
	if not ONLINE_JUDGE:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	t = 1
	t = inp()
	for tt in range(t):
		solve()
	if not ONLINE_JUDGE:
		print('Time Elapsed :', time.time() - start_time, 'seconds')
		sys.stdout.close()

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	return input().strip()

def invr():
	return map(int, input().split())

def counter(a):
	q = [0] * max(a)
	for i in range(len(a)):
		q[a[i] - 1] = q[a[i] - 1] + 1
	return q

def counter_elements(a):
	q = dict()
	for i in range(len(a)):
		if a[i] not in q:
			q[a[i]] = 0
		q[a[i]] = q[a[i]] + 1
	return q

def string_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
	return q

def factors(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
			q.append(n // i)
	return list(sorted(list(set(q))))

def prime_factors(n):
	q = []
	while n % 2 == 0:
		q.append(2)
		n = n // 2
	for i in range(3, int(n ** 0.5) + 1, 2):
		while n % i == 0:
			q.append(i)
			n = n // i
	if n > 2:
		q.append(n)
	return list(sorted(q))

def transpose(a):
	(n, m) = (len(a), len(a[0]))
	b = [[0] * n for i in range(m)]
	for i in range(m):
		for j in range(n):
			b[i][j] = a[j][i]
	return b

def factorial(n, m=1000000007):
	q = 1
	for i in range(n):
		q = q * (i + 1) % m
	return q
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
	input = sys.stdin.readline
main()


for __ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	dOdd = max(a)
	aOdd = list(map(lambda x: dOdd - x, a))
	dEven = max(aOdd)
	aEven = list(map(lambda x: dEven - x, aOdd))
	print(' '.join(map(str, aOdd))) if k % 2 else print(' '.join(map(str, aEven)))


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	maxi = max(l)
	for i in range(n):
		l[i] = maxi - l[i]
	if k % 2 != 0:
		print(*l)
	else:
		maxi = max(l)
		for i in range(n):
			l[i] = maxi - l[i]
		print(*l)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	b = k % 2
	for i in range(2 - b):
		a = max(l)
		for j in range(n):
			l[j] = a - l[j]
	print(*l)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if k >= 2:
		if k % 2 == 0:
			for i in range(2):
				d = max(a)
				for j in range(n):
					a[j] = d - a[j]
			print(*a, sep=' ')
		else:
			d = max(a)
			z = []
			for i in a:
				z.append(d - i)
			print(*z, sep=' ')
	else:
		d = max(a)
		z = []
		for i in a:
			z.append(d - i)
		print(*z, sep=' ')


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	l = [int(x) for x in input().split()]
	(a, b) = (max(l), min(l))
	if k & 1:
		for i in range(n):
			l[i] = -l[i] + a
	else:
		for i in range(n):
			l[i] = l[i] - b
	print(*l)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	a = []
	b = []
	for j in range(2):
		m = max(l)
		for i in range(n):
			l[i] = m - l[i]
		if j == 0:
			a = l.copy()
		else:
			b = l.copy()
	if k % 2 == 0:
		print(*b)
	else:
		print(*a)


def answer(n, k, A):
	d = max(A)
	maxi = -2147483647
	for i in range(n):
		A[i] = d - A[i]
		maxi = max(maxi, A[i])
	if k % 2 != 0:
		return A
	else:
		for i in range(n):
			A[i] = maxi - A[i]
		return A
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	print(*answer(n, k, arr))


import sys, bisect, string, math, time, functools, random, fractions
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, groupby
rep = range
R = range

def Golf():
	(n, *t) = map(int, open(0).read().split())

def I():
	return int(input())

def S_():
	return input()

def IS():
	return input().split()

def LS():
	return [i for i in input().split()]

def MI():
	return map(int, input().split())

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def NI(n):
	return [int(input()) for i in range(n)]

def NI_(n):
	return [int(input()) - 1 for i in range(n)]

def StoLI():
	return [ord(i) - 97 for i in input()]

def ItoS(n):
	return chr(n + 97)

def LtoS(ls):
	return ''.join([chr(i + 97) for i in ls])

def RA():
	return map(int, open(0).read().split())

def RLI(n=8, a=1, b=10):
	return [random.randint(a, b) for i in range(n)]

def RI(a=1, b=10):
	return random.randint(a, b)

def Rtest(T):
	(case, err) = (0, 0)
	for i in range(T):
		inp = INP()
		(a1, ls) = naive(*inp)
		a2 = solve(*inp)
		if a1 != a2:
			print((a1, a2), inp)
			err += 1
		case += 1
	print('Tested', case, 'case with', err, 'errors')

def GI(V, E, ls=None, Directed=False, index=1):
	org_inp = []
	g = [[] for i in range(V)]
	FromStdin = True if ls == None else False
	for i in range(E):
		if FromStdin:
			inp = LI()
			org_inp.append(inp)
		else:
			inp = ls[i]
		if len(inp) == 2:
			(a, b) = inp
			c = 1
		else:
			(a, b, c) = inp
		if index == 1:
			a -= 1
			b -= 1
		aa = (a, c)
		bb = (b, c)
		g[a].append(bb)
		if not Directed:
			g[b].append(aa)
	return (g, org_inp)

def GGI(h, w, search=None, replacement_of_found='.', mp_def={'#': 1, '.': 0}, boundary=1):
	mp = [boundary] * (w + 2)
	found = {}
	for i in R(h):
		s = input()
		for char in search:
			if char in s:
				found[char] = (i + 1) * (w + 2) + s.index(char) + 1
				mp_def[char] = mp_def[replacement_of_found]
		mp += [boundary] + [mp_def[j] for j in s] + [boundary]
	mp += [boundary] * (w + 2)
	return (h + 2, w + 2, mp, found)

def TI(n):
	return GI(n, n - 1)

def accum(ls):
	rt = [0]
	for i in ls:
		rt += [rt[-1] + i]
	return rt

def bit_combination(n, base=2):
	rt = []
	for tb in R(base ** n):
		s = [tb // base ** bt % base for bt in R(n)]
		rt += [s]
	return rt

def gcd(x, y):
	if y == 0:
		return x
	if x % y == 0:
		return y
	while x % y != 0:
		(x, y) = (y, x % y)
	return y

def YN(x):
	print(['NO', 'YES'][x])

def Yn(x):
	print(['No', 'Yes'][x])

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
mo = 10 ** 9 + 7
inf = float('inf')
FourNb = [(-1, 0), (1, 0), (0, 1), (0, -1)]
EightNb = [(-1, 0), (1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (1, -1), (-1, 1)]
compas = dict(zip('WENS', FourNb))
cursol = dict(zip('LRUD', FourNb))
l_alp = string.ascii_lowercase
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
input = lambda : sys.stdin.readline().rstrip()
show_flg = False
show_flg = True
ans = 0

def solve(a, k):
	n = len(a)
	if k % 2 == 1:
		k = 1
	else:
		k = 2
	for i in range(k):
		m = max(a)
		a = [m - j for j in a]
	print(*a)
for _ in range(I()):
	(n, k) = LI()
	a = LI()
	solve(a, k)


for t in range(int(input())):
	(n, k) = list(map(int, input().split()))
	num = list(map(int, input().split()))
	nm = max(num)
	if len(num) == 1:
		nm = 0
		num = 0
		print(0)
		continue
	for data in range(len(num)):
		num[data] = nm - num[data]
	if k % 2 == 0:
		nm = max(num)
		for data in range(len(num)):
			num[data] = nm - num[data]
	for data in num:
		print(data, sep=' ', end=' ')
	print()


try:
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		l = list(map(int, input().split()))
		a = max(l)
		a1 = [a - i for i in l]
		b = max(a1)
		b1 = [b - i for i in a1]
		if k % 2 == 0:
			print(*b1)
		else:
			print(*a1)
except:
	pass


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	list1 = list(map(int, input().split()))
	(li, l2, l3) = ([], [], [])
	if b % 2 == 0:
		n = max(list1)
		for i in list1:
			li.append(n - i)
		d = max(li)
		for i in li:
			l2.append(d - i)
		print(*l2)
	else:
		e = max(list1)
		for i in list1:
			l3.append(e - i)
		print(*l3)


cases = int(input())
for _ in range(cases):
	(n, k) = map(int, input().split())
	c = list(map(int, input().split()))
	if k == 0:
		print(c)
	else:
		r = max(c)
		for i in range(len(c)):
			c[i] = r - c[i]
		d = max(c)
		e = c.copy()
		for i in range(len(c)):
			e[i] = d - e[i]
		if k % 2 == 1:
			print(*c)
		else:
			print(*e)


import sys
from os import path
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def solve():
	(n, k) = [int(i) for i in input().rstrip().split()]
	a = [int(i) for i in input().rstrip().split()]
	k = 1 if k % 2 == 1 else 2
	for i in range(k):
		d = max(a)
		for idx in range(n):
			a[idx] = d - a[idx]
	print(' '.join((str(i) for i in a)))

def main():
	tc = int(input().strip())
	for case in range(tc):
		solve()
main()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	maxa = max(a)
	a = [maxa - el for el in a]
	if k % 2 == 0:
		maxa = max(a)
		a = [maxa - el for el in a]
	print(' '.join(map(str, a)))


n = int(input())
for _ in range(n):
	(n1, n2) = map(int, input().split())
	l = list(map(int, input().split()))
	l1 = max(l)
	f1 = []
	f2 = []
	for i in range(len(l)):
		f1.append(l1 - l[i])
	max2 = max(f1)
	for i in range(len(f1)):
		f2.append(max2 - f1[i])
	if n2 % 2 == 0:
		print(*f2)
	else:
		print(*f1)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	lis = list(map(int, input().split()))
	gr = max(lis)
	while k > 0:
		ma = gr
		ini = 0
		for i in range(n):
			lis[i] = ma - lis[i]
			if lis[i] >= ini:
				ini = lis[i]
				gr = ini
		k -= 1
		if gr == ma:
			break
		elif gr == 0:
			break
	if gr == 0:
		print('0 ' * n)
	elif k % 2 == 0:
		print(*lis)
	else:
		for i in lis:
			if i == gr:
				print(0, end=' ')
			elif i == 0:
				print(gr, end=' ')
			else:
				print(gr - i, end=' ')
		print()


t = int(input())
for _ in range(t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	elems = list(input().split())
	elems = list(map(int, elems))
	maxno = max(elems)
	elems = [maxno - elem for elem in elems]
	if k % 2 == 1:
		print(*elems, sep=' ')
	else:
		maxno = max(elems)
		elems = [maxno - elem for elem in elems]
		print(*elems, sep=' ')


tests = int(input())
for i in range(tests):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if len(a) == 1:
		print(0)
	else:
		d = max(a)
		a_ungerade = [0] * n
		a_gerade = [0] * n
		for s in range(n):
			a_ungerade[s] = d - a[s]
		if k % 2 == 1:
			print(*a_ungerade)
		else:
			d = max(a_ungerade)
			for s in range(n):
				a_gerade[s] = d - a_ungerade[s]
			print(*a_gerade)


t = int(input())
while t:
	(n, k) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	x = max(a)
	for i in range(0, len(a)):
		a[i] = x - a[i]
	k = k - 1
	if k % 2 == 0:
		print(*a, sep=' ')
	else:
		x = max(a)
		for i in range(0, len(a)):
			a[i] = x - a[i]
		print(*a, sep=' ')
	t = t - 1


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	d = max(a)
	b = []
	d1 = 0
	for i in range(len(a)):
		item = d - a[i]
		b.append(item)
		if item > d1:
			d1 = item
	c = []
	d2 = 0
	for i in range(len(b)):
		item = d1 - b[i]
		c.append(item)
		if item > d2:
			d2 = item
	if k % 2 != 0:
		print(' '.join(map(str, b)))
	else:
		print(' '.join(map(str, c)))


for _ in range(int(input())):
	(n, k) = (int(x) for x in input().split())
	arr = [int(j) for j in input().split()]
	for i in range(k):
		d = max(arr)
		for j in range(n):
			arr[j] = d - arr[j]
		if i == 3 and k % 2 == 0:
			break
		elif i == 4 and k % 2 == 1:
			break
	print(*arr)


def myPrint(a):
	s = ' '.join([str(x) for x in a])
	print(s)
N = int(input())
for _ in range(N):
	line = input()
	line = line.split()
	n = int(line[0])
	k = int(line[1])
	a = [0] * n
	line = input()
	values = line.split()
	for i in range(n):
		a[i] = int(values[i])
	d = max(a)
	for i in range(n):
		a[i] = d - a[i]
	k -= 1
	if k % 2 == 0:
		myPrint(a)
	else:
		d = max(a)
		for i in range(n):
			a[i] = d - a[i]
		myPrint(a)


test_cases = int(input())
for test_case in range(test_cases):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	count = 0
	ans = ''
	while True:
		d = max(a)
		for i in range(len(a)):
			a[i] = d - a[i]
		count += 1
		if k % 2 == 0 and count == 2:
			break
		elif k % 2 != 0 and count == 1:
			break
	print(*a)


num_test = int(input())
for i in range(num_test):
	[n, k] = list(map(int, input().split()))
	a = list(map(int, input().split()))
	if k % 2 == 1:
		max_val = max(a)
		for j in range(n):
			a[j] = max_val - a[j]
	if k % 2 == 0:
		for q in range(2):
			max_val = max(a)
			for j in range(n):
				a[j] = max_val - a[j]
	for q in range(n):
		print(a[q], end=' ')
	print('\n')


from sys import stdout, stdin
(_input, _print) = (stdin.readline, stdout.write)
(_int, _range, _max, _min) = (int, range, max, min)

def solution():
	for _ in _range(_int(_input())):
		(n, k) = [_int(i) for i in _input().split()]
		arr = [_int(i) for i in _input().split()]
		minimal = _min(arr)
		if k > 1 and minimal < 0:
			for i in _range(n):
				arr[i] = arr[i] - minimal
			k -= 2
		elif k > 0 and minimal >= 0:
			maximal = _max(arr)
			for i in _range(n):
				arr[i] = maximal - arr[i]
			k -= 1
		k %= 2
		if k > 0:
			maximal = _max(arr)
			for i in _range(n):
				arr[i] = maximal - arr[i]
			k -= 1
		print(*arr)
solution()


import sys
import heapq
import math
from collections import deque
from collections import defaultdict
from collections import Counter
modH = int(10 ** 9) + 7
I = lambda : list(map(int, input().split(' ')))

def PRINT(lst, sep=' '):
	print(sep.join(map(str, lst)))
for _ in range(int(input())):
	(n, k) = I()
	lst = I()
	maxx = max(lst)
	minn = min(lst)
	if k % 2 == 1:
		PRINT(list(map(lambda x: maxx - x, lst)))
	else:
		PRINT(list(map(lambda x: x - minn, lst)))


from sys import maxsize
for ii in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	hs = set(a)
	mm = -maxsize
	for i in range(0, n):
		if a[i] > mm:
			mm = a[i]
	for i in range(0, n):
		a[i] = mm - a[i]
	if k % 2 == 0:
		mm = -maxsize
		for i in range(0, n):
			if a[i] > mm:
				mm = a[i]
		for i in range(0, n):
			a[i] = mm - a[i]
	for i in range(0, n):
		print(a[i], end=' ')
	print()


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	d = max(l)
	if k % 2 == 0:
		l = [d - x for x in l]
		d = max(l)
		l = [d - x for x in l]
	else:
		l = [d - x for x in l]
	print(' '.join(map(str, l)))


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
from collections import deque
from heapq import heappush, heappop, heapify
mod = int(1000000000.0) + 7
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
t = ip()
for _ in range(t):
	(n, k) = inp()
	arr = list(inp())
	ch = max(arr)
	for i in range(n):
		arr[i] = ch - arr[i]
	k -= 1
	if k == 0:
		pass
	elif k % 2 == 0:
		pass
	else:
		ch = max(arr)
		for i in range(n):
			arr[i] = ch - arr[i]
	print(*arr)


import sys
t = int(input())
while t > 0:
	t -= 1
	(n, k) = input().strip().split()
	(n, k) = (int(n), int(k))
	arr = input().strip().split()
	arr = [int(ele) for ele in arr]
	min_ele = 10 ** 9 + 1
	max_ele = -(10 ** 9 + 1)
	for ele in arr:
		min_ele = min(min_ele, ele)
		max_ele = max(max_ele, ele)
	if k % 2 == 0:
		output_arr = [str(ele - min_ele) for ele in arr]
	else:
		output_arr = [str(max_ele - ele) for ele in arr]
	print(' '.join(output_arr))


t = int(input(''))
arr = []
num = []
for i in range(t):
	num.append(list(map(int, input().split())))
	arr.append(list(map(int, input().split())))
for i in range(t):
	tst = arr[i]
	n = num[i][0]
	k = num[i][1]
	mx = max(tst)
	for j in range(n):
		tst[j] = mx - tst[j]
	if k % 2:
		print(*tst)
	else:
		mx = max(tst)
		for j in range(n):
			tst[j] = mx - tst[j]
		print(*tst)


from collections import Counter
import math
import sys
from bisect import bisect, bisect_left, bisect_right

def input():
	return sys.stdin.readline().strip()

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def mod():
	return 10 ** 9 + 7
for i in range(INT()):
	(n, k) = MAP()
	arr = LIST()
	d = max(arr)
	for i in range(n):
		arr[i] = d - arr[i]
	if k == 1:
		print(*arr)
	else:
		d1 = max(arr)
		for i in range(n):
			arr[i] = d1 - arr[i]
		arr1 = arr.copy()
		d2 = max(arr1)
		for i in range(n):
			arr1[i] = d2 - arr1[i]
		if k % 2 == 0:
			print(*arr)
		else:
			print(*arr1)


import sys
import math, bisect
from collections import defaultdict
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, OrderedDict

def neo():
	return map(int, input().split())

def Neo():
	return list(map(int, input().split()))
for _ in range(int(input())):
	(n, k) = neo()
	A = Neo()
	m = max(A)
	for i in range(n):
		A[i] = m - A[i]
	Ans1 = A.copy()
	m = max(A)
	for i in range(n):
		A[i] = m - A[i]
	Ans2 = A.copy()
	if k == 1:
		print(*Ans1)
	elif k == 2:
		print(*Ans2)
	else:
		k += 1
		if k % 2 == 0:
			print(*Ans1)
		else:
			print(*Ans2)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	mina = min(a)
	maxa = max(a)
	if mina == maxa:
		print('0 ' * n)
	elif k % 2 != 0:
		for i in range(n):
			a[i] = maxa - a[i]
		print(*a)
	else:
		for i in range(n):
			a[i] -= mina
		print(*a)


def solve(lst, n, k):
	m = max(lst)
	i = 0
	while i < n:
		lst[i] = m - lst[i]
		i += 1
	if k % 2 == 0:
		m = max(lst)
		for j in range(n):
			lst[i] = m - lst[i]
	return lst
test = int(input())
for tt in range(test):
	(n, k) = map(int, input().split())
	lst = [int(j) for j in input().split()]
	ele = max(lst)
	i = 0
	for i in range(n):
		lst[i] = ele - lst[i]
	if k % 2 == 0:
		ele = max(lst)
		for j in range(n):
			lst[j] = ele - lst[j]
	print(*lst)


t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split(' ')]
	arr = [int(x) for x in input().split(' ')]
	if k % 2 == 1:
		m = max(arr)
		for i in range(n):
			arr[i] = m - arr[i]
		for i in arr:
			print(i, end=' ')
	else:
		m = max(arr)
		for i in range(n):
			arr[i] = m - arr[i]
		m = max(arr)
		for i in range(n):
			arr[i] = m - arr[i]
		for i in arr:
			print(i, end=' ')


import sys, math
from collections import deque, defaultdict
import operator as op
from functools import reduce
sys.setrecursionlimit(10 ** 6)
I = sys.stdin.readline

def ii():
	return int(I().strip())

def li():
	return list(map(int, I().strip().split()))

def mi():
	return map(int, I().strip().split())

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def main():
	for _ in range(ii()):
		(n, k) = mi()
		arr = li()
		d = max(arr)
		for j in range(n):
			arr[j] = d - arr[j]
		if k % 2:
			print(*arr)
		else:
			d = max(arr)
			for j in range(n):
				arr[j] = d - arr[j]
			print(*arr)
main()


t = int(input())
for test in range(t):
	(n, k) = [int(x) for x in input().split()]
	nums = [int(x) for x in input().split()]
	maxx = max(nums)
	minn = min(nums)
	first = []
	for i in range(n):
		first.append(maxx - nums[i])
	second = []
	maxx = max(first)
	for i in range(n):
		second.append(maxx - first[i])
	if k % 2 == 0:
		for i in range(n):
			print(second[i], end=' ')
		print(' ')
	else:
		for i in range(n):
			print(first[i], end=' ')
		print(' ')


from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right, insort
import random
import math
import heapq
from sys import stdin, stdout, setrecursionlimit
from functools import partial, cmp_to_key
from itertools import combinations, permutations
setrecursionlimit(100000)
maxN = 100000
M = 10 ** 9 + 7
t = int(input())
for _ in range(t):
	(n, k) = map(int, stdin.readline().rstrip().split())
	a = list(map(int, stdin.readline().rstrip().split()))
	mx = max(a)
	mn = min(a)
	d1 = mx
	d2 = mx - mn
	if k & 1:
		for i in range(n):
			a[i] = d1 - a[i]
	else:
		for i in range(n):
			a[i] = d2 - d1 + a[i]
	print(*a)


t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	lst = list(map(int, input().split()))
	maxi = max(lst)
	lst = [maxi - i for i in lst]
	maxi = max(lst)
	lst1 = [maxi - i for i in lst]
	maxi = max(lst1)
	lst2 = [maxi - i for i in lst1]
	if k % 2 == 0:
		print(*lst1)
	else:
		print(*lst2)


t = int(input())
for i in range(t):
	temp = [int(x) for x in input().split()]
	n = temp[0]
	k = temp[1]
	a = [int(x) for x in input().split()]
	if k % 2 != 0:
		d = max(a)
		for j in range(n):
			a[j] = d - a[j]
	else:
		for j in range(2):
			d = max(a)
			for l in range(n):
				a[l] = d - a[l]
	a = [str(x) for x in a]
	print(' '.join(a))


def solve(N, K, A):
	if K % 2 != 0:
		max_el = max(A)
		for i in range(N):
			A[i] = max_el - A[i]
	else:
		for i in range(2):
			max_el = max(A)
			for j in range(N):
				A[j] = max_el - A[j]
	print(*A)
t = int(input())
while t != 0:
	(n, k) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	solve(n, k, a)
	t -= 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	s1 = []
	s2 = []
	p = max(a)
	q = min(a)
	s = p - q
	for i in range(n):
		g = p - a[i]
		s1.append(g)
	for j in range(n):
		kl = s - s1[j]
		s2.append(kl)
	if k % 2 == 0:
		print(*s2)
	else:
		print(*s1)


from collections import Counter
t = int(input())
for i in range(t):
	(n, k) = input().split()
	m = int(n)
	p = int(k)
	a = list(map(int, input('').strip().split()))
	count = 0
	a1 = [0] * m
	a2 = [0] * m
	d = max(a)
	for j in range(len(a)):
		a1[j] = d - a[j]
	d = max(a1)
	for j in range(len(a)):
		a2[j] = d - a1[j]
	if p % 2 == 1:
		for j in a1:
			print(j, end=' ')
		print()
	if p % 2 == 0:
		for j in a2:
			print(j, end=' ')
		print()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	l = []
	m = max(a)
	for i in a:
		l.append(m - i)
	ll = []
	m = max(l)
	for i in l:
		ll.append(m - i)
	if k & 1:
		for i in l:
			print(i, end=' ')
	else:
		for i in ll:
			print(i, end=' ')
	print()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	d = max(a)
	d1 = float('-inf')
	for j in range(n):
		a[j] = d - a[j]
		d1 = max(d1, a[j])
	if k % 2:
		print(*a)
	else:
		for j in range(n):
			a[j] = d1 - a[j]
		print(*a)


import sys
input = sys.stdin.readline
(T,) = map(int, input().split())
for _ in range(T):
	(N, K) = map(int, input().split())
	X = list(map(int, input().split()))
	x = max(X)
	for i in range(N):
		X[i] = x - X[i]
	if K % 2:
		print(*X)
	else:
		x = max(X)
		for i in range(N):
			X[i] = x - X[i]
		print(*X)


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def solve():
	(n, k) = mints()
	a = list(mints())
	if k != 0:
		k = k % 2
		if k == 0:
			k = 2
		for j in range(k):
			m = max(a)
			b = [m - i for i in a]
			a = b
	print(' '.join(map(str, a)))
for i in range(mint()):
	solve()


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	d = max(a)
	d1 = d - min(a)
	a1 = [d - a[i] for i in range(n)]
	a2 = [d1 - a1[i] for i in range(n)]
	if k % 2 == 1:
		print(*a1)
	else:
		print(*a2)


from math import ceil, sqrt

def main():
	t = int(input())
	for i in range(t):
		(n, k) = map(int, input().split())
		values = list(map(int, input().split()))
		m = max(values)
		mi = min(values)
		for i in range(n):
			values[i] = m - values[i]
		k -= 1
		if k % 2 == 0:
			print(*values)
		else:
			for i in range(n):
				values[i] = m - mi - values[i]
			print(*values)
main()


for t in range(int(input())):
	(n, k) = map(int, input().split(' '))
	aa = list(map(int, input().split(' ')))
	k %= 2
	if k == 0:
		k = 2
	for iter in range(k):
		d = max(aa)
		aa = [d - a for a in aa]
	print(' '.join((str(a) for a in aa)))


import sys, os.path
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = a[:]
	b.sort(reverse=True)
	p = b[0]
	q = b[n - 1]
	for i in range(n):
		a[i] = p - a[i]
		b[i] = p - b[i]
	if k % 2:
		print(*a)
	else:
		b.sort(reverse=True)
		p = b[0]
		q = b[n - 1]
		for i in range(n):
			a[i] = p - a[i]
		print(*a)


t = int(input())
arrs = []
for i in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	maax = max(arr)
	if k % 2 != 0:
		for i in range(n):
			arr[i] = maax - arr[i]
	else:
		for i in range(n):
			arr[i] = maax - arr[i]
		maax = max(arr)
		for i in range(n):
			arr[i] = maax - arr[i]
	arrs.append(arr)
for i in range(len(arrs)):
	for j in range(len(arrs[i])):
		print(arrs[i][j], end=' ')
	print()


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(x, y) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	d = max(l)
	for i in range(x):
		l[i] = d - l[i]
	if x == 1:
		print(0)
	elif y % 2 == 1:
		print(*l)
	else:
		d = max(l)
		for i in range(x):
			l[i] = d - l[i]
		print(*l)


T = int(input())
for t in range(T):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	maxx = max(a)
	minn = min(a)
	x = k % 2
	if x == 0:
		for y in a:
			print(y - minn, end=' ')
	else:
		for y in a:
			print(maxx - y, end=' ')
	print()


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	mx = max(arr)
	ans1 = [mx - item for item in arr]
	mx = max(ans1)
	ans2 = [mx - item for item in ans1]
	if k & 1:
		ans = [str(x) for x in ans1]
		print(' '.join(ans))
	else:
		ans = [str(x) for x in ans2]
		print(' '.join(ans))


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return [int(i) for i in input().split()]

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	new_number = 0
	while number > 0:
		new_number += number % base
		number //= base
	return new_number

def cdiv(n, k):
	return n // k + (n % k != 0)

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True
for _ in range(ii()):
	(n, k) = mi()
	a = li()
	b = []
	(min_, max_) = (min(a), max(a))
	if n == 1:
		print(0)
	elif k & 1:
		for i in range(n):
			b.append(max_ - a[i])
		print(*b)
	else:
		for i in range(n):
			b.append(a[i] - min_)
		print(*b)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	(Min, Max) = (min(arr), max(arr))
	if k & 1 != 0:
		for i in range(n):
			arr[i] = Max - arr[i]
	else:
		for i in range(n):
			arr[i] = arr[i] - Min
	print(*arr)


import sys
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	g = []
	g = list(map(int, input().split()))
	m = max(g)
	for j in range(n):
		g[j] = m - g[j]
	m = max(g)
	if k % 2 == 1:
		print(' '.join(map(str, g)))
	else:
		for j in range(n):
			g[j] = m - g[j]
		print(' '.join(map(str, g)))


TC = int(input())
for tc in range(TC):
	(N, K) = map(int, input().split())
	A = list(map(int, input().split()))
	min_a = A[0]
	max_a = A[0]
	for a in A:
		min_a = min(min_a, a)
		max_a = max(max_a, a)
	result = A.copy()
	if K % 2 == 0:
		for (i, a) in enumerate(A):
			result[i] = a - min_a
	else:
		for (i, a) in enumerate(A):
			result[i] = max_a - a
	for r in result:
		print(r, end=' ')
	print()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	mx = -10 ** 9
	mn = 10 ** 9
	for i in range(n):
		mx = max(mx, a[i])
		mn = min(mn, a[i])
	if k % 2 != 0:
		print(*(mx - v for v in a))
	else:
		print(*(v - mn for v in a))


test = int(input())
result = []
for t in range(test):
	nk = [int(num) for num in input().split()]
	arr = [int(n) for n in input().split()]
	if nk[1] % 2 != 0:
		a = max(arr)
		nArr = [a - x for x in arr]
	else:
		b = min(arr)
		nArr = [x - b for x in arr]
	result.append(nArr)
for count in range(len(result)):
	print(*result[count])


import sys
input = sys.stdin.readline
t = int(input())
for t1 in range(t):
	(n, k) = list(map(int, input().split(' ')))
	l = list(map(int, input().split(' ')))
	k -= 1
	ans = max(l) - min(l)
	s = ''
	z = max(l)
	for i in range(len(l)):
		l[i] = z - l[i]
	if k % 2 != 0:
		for i in range(len(l)):
			l[i] = ans - l[i]
	for i in range(len(l)):
		l[i] = str(l[i])
	print(' '.join(l))


test = int(input())
for _ in range(test):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	mini = min(arr)
	maxi = max(arr)
	first = []
	for i in range(n):
		first.append(maxi - arr[i])
	maxi = max(first)
	second = []
	for i in range(n):
		second.append(maxi - first[i])
	if k % 2:
		for i in range(n):
			print(first[i], end=' ')
		print()
	else:
		for i in range(n):
			print(second[i], end=' ')
		print()


import sys
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict

def solve(lst, k):
	console('----- solving ------')
	maxx = max(lst)
	lst = [maxx - x for x in lst]
	if k == 1:
		return lst
	maxx = max(lst)
	lst = [maxx - x for x in lst]
	if k == 2:
		return lst
	maxx = max(lst)
	lst = [maxx - x for x in lst]
	if k % 2:
		return lst
	maxx = max(lst)
	lst = [maxx - x for x in lst]
	return lst

def console(*args):
	print('\x1b[36m', *args, '\x1b[0m', file=sys.stderr)
	return
for case_num in range(int(input())):
	(_, k) = list(map(int, input().split()))
	lst = list(map(int, input().split()))
	res = solve(lst, k)
	print(' '.join((str(x) for x in res)))


for t in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	maxm = max(l)
	lst1 = []
	lst2 = []
	for i in range(n):
		lst1.append(maxm - l[i])
	maxm1 = max(lst1)
	for i in range(n):
		lst2.append(maxm1 - lst1[i])
	if k % 2 == 1:
		print(*lst1)
	else:
		print(*lst2)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	zero = a.count(0)
	mx = max(a)
	b = a[:]
	c = a[:]
	while k:
		k -= 1
		mx = max(c)
		for i in range(n):
			c[i] = mx - c[i]
		if c == a:
			break
		a = b[:]
		b = c[:]
	k += 1
	par = k % 2
	if par:
		print(*c)
	else:
		print(*b)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = a[:]
	b.sort(reverse=True)
	p = b[0]
	q = b[n - 1]
	for i in range(n):
		a[i] = p - a[i]
		b[i] = p - b[i]
	if k % 2:
		print(*a)
	else:
		b.sort(reverse=True)
		p = b[0]
		q = b[n - 1]
		for i in range(n):
			a[i] = p - a[i]
		print(*a)


def replace(n, arr, x):
	for i in range(n):
		arr[i] = x - arr[i]
	return arr
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	if k > 1:
		k = k - 2 * (k // 2) + 2
	for i in range(k):
		if i % 2 == 0:
			arr = replace(n, arr, max(arr))
		else:
			arr = replace(n, arr, max(arr))
	print(*arr)


import sys

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s)
	sys.stdout.write('\n')

def wi(n):
	sys.stdout.write(str(n))
	sys.stdout.write('\n')

def wia(a, sep=' '):
	sys.stdout.write(sep.join([str(x) for x in a]))
	sys.stdout.write('\n')

def solve(n, k, a):
	kk = min(k, 10)
	for d in range(kk):
		mx = max(a)
		a = [mx - ai for ai in a]
	for d in range((k - kk) % 2):
		mx = max(a)
		a = [mx - ai for ai in a]
	return a

def main():
	for _ in range(ri()):
		(n, k) = ria()
		a = ria()
		wia(solve(n, k, a))
main()


for i in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	d = max(l)
	for i in range(len(l)):
		l[i] = abs(d - l[i])
	if k % 2 != 0:
		print(*l)
	else:
		a = max(l)
		for i in range(len(l)):
			l[i] = abs(a - l[i])
		print(*l)


t = int(input())
for i in range(t):
	m = list(map(int, input().split()))
	n = m[0]
	k = m[1]
	l = list(map(int, input().split()))
	mx = max(l)
	p = []
	q = []
	for i in range(len(l)):
		l[i] = mx - l[i]
		p.append(l[i])
	d = max(l)
	for j in range(len(l)):
		l[j] = d - l[j]
		q.append(l[j])
	if k % 2 != 0:
		print(*p)
	else:
		print(*q)


for _ in range(int(input())):
	(n, k) = map(int, input().split(' '))
	l = list(map(int, input().split(' ')))
	temp = []
	for i in range(2):
		d = max(l)
		for j in range(len(l)):
			l[j] = d - l[j]
		temp.append(l.copy())
	if k % 2 == 0:
		l = temp[1].copy()
	else:
		l = temp[0].copy()
	for i in l:
		print(i, end=' ')
	print()


T = int(input())
for i in range(T):
	[N, K] = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	d = max(arr)
	arr1 = [d - i for i in arr]
	if K % 2 != 0:
		print(*arr1)
	else:
		d = max(arr1)
		arr2 = [d - i for i in arr1]
		print(*arr2)


def next():
	d = max(a)
	for i in range(n):
		a[i] = d - a[i]
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	for i in range(1 + (k - 1) % 2):
		next()
	print(*a)


def ans_finder(a, k):
	temp = a.copy()
	for i in range(2):
		d = max(a)
		for i in range(len(a)):
			a[i] = d - a[i]
	d = max(temp)
	for i in range(len(temp)):
		temp[i] = d - temp[i]
	if k % 2 == 0:
		return a
	else:
		return temp
t = int(input())
ans = []
for i in range(t):
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	ans.append(ans_finder(a, k))
for i in ans:
	print(*i)


t = int(input())
for _ in range(t):
	(n, k) = list(map(lambda x: int(x), input().split()))
	a = list(map(lambda x: int(x), input().split()))
	d = max(a)
	for i in range(0, len(a)):
		a[i] = d - a[i]
	if k == 1:
		for i in a:
			print(i, end=' ')
		print()
	else:
		first = a
		d = max(first)
		second = [d - x for x in a]
		if k % 2 == 0:
			for i in second:
				print(i, end=' ')
			print()
		else:
			for i in first:
				print(i, end=' ')
			print()


def solve(nums, n, k):
	max_num = max(nums)
	odd_nums = [max_num - num for num in nums]
	max_num = max(odd_nums)
	even_nums = [max_num - num for num in odd_nums]
	return odd_nums if k % 2 else even_nums
for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	nums = list(map(int, input().split()))
	print(' '.join(map(str, solve(nums, n, k))))


from sys import stdin
input = stdin.buffer.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	(*a,) = map(int, input().split())
	if min(a):
		d = max(a)
		a = [d - i for i in a]
		k -= 1
	d = max(a)
	b = [d - i for i in a]
	if k & 1:
		print(*b)
	else:
		print(*a)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	m = max(a)
	l = []
	for i in range(n):
		a[i] = m - a[i]
	l.append(a.copy())
	m = max(a)
	for i in range(n):
		a[i] = m - a[i]
	l.append(a.copy())
	print(*l[(k - 1) % 2])


from collections import *
import sys

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))
t = ri()
for _ in range(t):
	(n, k) = rl()
	aa = rl()
	aa1 = [0] * n
	aa2 = [0] * n
	maxou = max(aa)
	for (i, ai) in enumerate(aa):
		aa1[i] = maxou - ai
	maxou1 = max(aa1)
	for (i, ai) in enumerate(aa1):
		aa2[i] = maxou1 - ai
	if k % 2 == 1:
		print(*aa1)
	else:
		print(*aa2)


from sys import stdin

def inp():
	return stdin.buffer.readline().rstrip().decode('utf8')

def itg():
	return int(stdin.buffer.readline())

def mpint():
	return map(int, stdin.buffer.readline().split())
for case in range(1, itg() + 1):
	(n, k) = mpint()
	arr = list(mpint())
	d = max(arr)
	for i in range(n):
		arr[i] = d - arr[i]
	k -= 1
	if k:
		k -= 1
		d = max(arr)
		for i in range(n):
			arr[i] = d - arr[i]
	if k & 1:
		k -= 1
		d = max(arr)
		for i in range(n):
			arr[i] = d - arr[i]
	print(*arr)


from collections import defaultdict
from sys import stdin
inp = lambda : stdin.readline().strip()
t = int(inp())
for _ in range(t):
	(n, k) = [int(x) for x in inp().split()]
	a = [int(x) for x in inp().split()]
	ans1 = []
	ans2 = []
	maxA = max(a)
	for i in a:
		ans1.append(maxA - i)
	maxAns = max(ans1)
	for i in ans1:
		ans2.append(maxAns - i)
	if k % 2:
		print(*ans1)
	else:
		print(*ans2)


for _ in ' ' * int(input()):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	mx = max(a)
	mn = min(a)
	lst = []
	lst1 = []
	for i in range(n):
		lst.append(mx - a[i])
		lst1.append(a[i] - mn)
	if k % 2:
		print(*lst)
	else:
		print(*lst1)


t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	min1 = min(a)
	max1 = max(a)
	if k % 2 == 1:
		b = []
		for i in range(n):
			b.append(max1 - a[i])
		print(*b, sep=' ')
	else:
		b = []
		for i in range(n):
			b.append(a[i] - min1)
		print(*b, sep=' ')


t = int(input())

def do_operation(arr):
	mx = max(arr)
	return [mx - el for el in arr]

def print_arr(arr):
	print(' '.join(map(str, arr)))
for _ in range(t):
	(n, k) = map(int, input().split())
	orig = list(map(int, input().split()))
	odd_state = do_operation(orig)
	even_state = do_operation(odd_state)
	if k == 0:
		print_arr(orig)
	elif k & 1:
		print_arr(odd_state)
	else:
		print_arr(even_state)


t = int(input())
while t:
	t -= 1
	(n, k) = input().split(' ')
	(n, k) = (int(n), int(k))
	a = input().split(' ')
	if n == 1:
		print(0)
	else:
		for i in range(n):
			a[i] = int(a[i])
		d = []
		kk = 2
		while kk:
			kk -= 1
			ma = max(a)
			for i in range(n):
				a[i] = ma - a[i]
			if a not in d:
				d.append(a.copy())
			else:
				break
		if k % 2 == 0:
			for i in d[1]:
				print(i, end=' ')
			print()
		else:
			for i in d[0]:
				print(i, end=' ')
			print()


def apl(arr, mod, sign):
	return [mod + sign * v for v in arr]
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	(*arr,) = map(int, input().split())
	mod = 0
	sign = 1
	mx = max(arr)
	k -= 1
	arr = [mx - v for v in arr]
	if k % 2 == 0:
		print(*arr)
	else:
		mx = max(arr)
		print(*[mx - v for v in arr])


from sys import stdin, stdout
test = int(stdin.readline())
for _ in range(test):
	(n, k) = map(int, stdin.readline().split())
	a = [int(x) for x in stdin.readline().split()]
	poss = [[], []]
	for i in range(2):
		maxx = max(a)
		for j in range(n):
			a[j] = maxx - a[j]
			poss[i].append(a[j])
	print(*poss[k & 1 ^ 1])


def maxi(arr):
	m = max(arr)
	arr = [m - x for x in arr]
	return arr

def pr(arr):
	for i in arr:
		print(i, end=' ')
	print('\n')
t = int(input())
a = [[]] * t
m = [0] * t
for i in range(t):
	(n, k) = map(int, input().split())
	m[i] = k
	a[i] = list(map(int, input().strip().split()))[:n]
for i in range(t):
	a1 = maxi(a[i])
	a2 = maxi(a1)
	if m[i] % 2 != 0:
		pr(a1)
	else:
		pr(a2)


def f(a, k):
	d = max(a)
	if k == 0:
		return a
	else:
		for i in range(len(a)):
			a[i] = d - a[i]
		if max(a) == d:
			return f(a, (k + 1) % 2)
		else:
			return f(a, k - 1)
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	print(*f(a, m))


from sys import stdin, stdout
t = int(stdin.readline())
for _ in range(t):
	(n, k) = map(int, stdin.readline().split())
	ar = list(map(int, stdin.readline().split()))
	if k == 0:
		for i in ar:
			print(i, end=' ')
		print()
		continue
	maxi = max(ar)
	mini = min(ar)
	for i in range(n):
		ar[i] = maxi - ar[i]
	if k % 2 != 0:
		for i in ar:
			print(i, end=' ')
	else:
		nmax = max(ar)
		for i in ar:
			print(nmax - i, end=' ')
	print()


t = int(input())
while t:
	t -= 1
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	k = max(l)
	o = []
	for i in l:
		o.append(k - i)
	k = max(o)
	e = []
	for i in o:
		e.append(k - i)
	if m & 1:
		for i in o:
			print(i, end=' ')
		print('\n')
	else:
		for i in e:
			print(i, end=' ')
		print('\n')


from fractions import Fraction
import bisect
import os
import io
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate
from queue import Queue

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
t = 1
t = iinput()
for _ in range(t):
	(n, k) = rinput()
	a = rlinput()
	state1 = []
	state2 = []
	mx = max(a)
	for i in range(n):
		state1.append(mx - a[i])
	mx = max(state1)
	for i in range(n):
		state2.append(mx - state1[i])
	if k % 2:
		print(*state1)
	else:
		print(*state2)


import os
import sys
from io import BytesIO, IOBase

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()

def test():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	d = sorted(a)[-1]
	for i in range(2 + k % 2):
		for j in range(len(a)):
			a[j] = abs(a[j] - d)
		d = sorted(a)[-1]
	print(*a)
t = int(input())
for _ in range(t):
	test()


t = int(input())
for i in range(0, t):
	w = list(map(int, input().split()))
	l = list(map(int, input().split()))
	if w[1] % 2 != 0:
		m = max(l)
		n = w[0]
		for i in range(0, n):
			print(m - l[i], end=' ')
		print()
	else:
		m = max(l)
		n = w[0]
		for i in range(0, n):
			l[i] = m - l[i]
		m = max(l)
		for i in range(0, n):
			print(m - l[i], end=' ')
		print()


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	lis = list(map(int, input().split()))
	m = max(lis)
	for i in range(n):
		lis[i] = m - lis[i]
	k -= 1
	lis1 = [*lis]
	m = max(lis)
	for i in range(n):
		lis[i] = m - lis[i]
	lis2 = [*lis]
	if k % 2:
		print(*lis2)
	else:
		print(*lis1)


T = int(input())
for test in range(T):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	if k % 2 == 0:
		minval = min(a)
		print(' '.join([str(x - minval) for x in a]))
	else:
		maxval = max(a)
		print(' '.join([str(maxval - x) for x in a]))


from itertools import accumulate as ac
from collections import Counter as cc
from bisect import bisect_left as bsl
from bisect import bisect as bs
from math import factorial as f
from collections import *
from itertools import *
from string import *
from bisect import *
from queue import *
from heapq import *
from math import *
from sys import *
from re import *

def fast():
	return stdin.readline().strip()

def zzz():
	return [int(i) for i in fast().split()]
(z, zz) = (input, lambda : list(map(int, z().split())))
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def output(answer):
	stdout.write(str(answer))
num = int(z())
for _ in range(num):
	(n, k) = zzz()
	arr = zzz()
	lst = []
	for i in range(2):
		m = max(arr)
		new = [0] * n
		for j in range(n):
			new[j] = m - arr[j]
		lst.append(new)
		arr = new
	print(*lst[(k + 1) % 2])


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	c = max(a)
	d = []
	for i in range(n):
		d.append(c - a[i])
	e = []
	c = max(d)
	for i in range(n):
		e.append(c - d[i])
	if k % 2 != 0:
		print(*d)
	else:
		print(*e)


t = int(input())
for case in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	if n == 1:
		print(0)
	else:
		m = max(arr)
		arr = list(map(lambda x: m - x, arr))
		m = max(arr)
		if k - 1 & 1:
			print(' '.join(map(str, map(lambda x: m - x, arr))))
		else:
			print(' '.join(map(str, arr)))


def solve(n, k, arr, ans):
	one = arr[:]
	d = max(arr)
	for i in range(n):
		one[i] = d - one[i]
	two = one[:]
	d = max(two)
	for i in range(n):
		two[i] = d - two[i]
	k %= 2
	if k:
		for i in range(n):
			one[i] = str(one[i])
		ans.append(one)
	else:
		for i in range(n):
			two[i] = str(two[i])
		ans.append(two)

def main():
	t = int(input())
	ans = []
	for i in range(t):
		(n, k) = map(int, input().split())
		arr = list(map(int, input().split()))
		solve(n, k, arr, ans)
	for i in ans:
		print(' '.join(i))
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	li = list(map(int, input().split()))
	li1 = [0] * n
	li2 = [0] * n
	m = max(li)
	for i in range(n):
		li1[i] = m - li[i]
	z = max(li1)
	for j in range(n):
		li2[j] = z - li1[j]
	if k % 2 == 1:
		print(*li1)
	else:
		print(*li2)


import sys
from collections import defaultdict
input = sys.stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	lis = list(map(int, input().split()))
	m = max(lis)
	res1 = [0] * n
	res2 = [0] * n
	for i in range(n):
		res1[i] = m - lis[i]
	m = max(res1)
	for i in range(n):
		res2[i] = m - res1[i]
	if k % 2 == 0:
		print(*res2)
	else:
		print(*res1)


t = int(input())

def nechet(a):
	d = max(a)
	for i in range(len(a)):
		a[i] = d - a[i]
	return a
for i in range(t):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	if k % 2 == 0:
		print(*nechet(nechet(a)))
	else:
		print(*nechet(a))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	d = []
	s = []
	x = max(l)
	for j in range(len(l)):
		d.append(x - l[j])
	a = max(d)
	for v in range(len(d)):
		s.append(a - d[v])
	if k % 2 == 1:
		print(*d)
	else:
		print(*s)


t = int(input())
while t:
	t = t - 1
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if k % 2 == 0:
		k = 2
	else:
		k = 1
	for i in range(k):
		maxx = max(a)
		for j in range(n):
			a[j] = maxx - a[j]
	print(*a)


import os
import heapq
import sys
import math
import operator
from collections import defaultdict, deque
from io import BytesIO, IOBase

def inpt():
	return [int(k) for k in input().split()]

def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		ar = inpt()
		mx = max(ar)
		for i in range(n):
			ar[i] = mx - ar[i]
		k -= 1
		if k & 1:
			mx = max(ar)
			for i in range(n):
				ar[i] = mx - ar[i]
		for i in ar:
			print(i, end=' ')
		print()
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	(am, k) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	mi = min(arr)
	ma = max(arr)
	if k & 1:
		if mi == ma:
			print('0 ' * am)
		else:
			for i in range(am):
				arr[i] = ma - arr[i]
			print(*arr)
	elif mi == ma:
		print('0 ' * am)
	else:
		for i in range(am):
			arr[i] -= mi
		print(*arr)


for _ in range(int(input())):
	(a, c) = map(int, input().split())
	c -= 1
	b = list(map(int, input().split()))
	maxx = -10 ** 20
	for i in b:
		maxx = max(maxx, i)
	for i in range(a):
		b[i] = maxx - b[i]
	if c % 2 == 0:
		print(*b)
	else:
		maxx = -10 ** 20
		for i in b:
			maxx = max(maxx, i)
		for i in range(a):
			b[i] = maxx - b[i]
		print(*b)


t = int(input())
myList = []
for _ in range(t):
	s = []
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	M = max(a)
	m = min(a)
	if k % 2 == 0 and k > 0:
		for j in range(n):
			s.append(a[j] - m)
	elif k % 2 == 1:
		for i in range(n):
			s.append(M - a[i])
	else:
		s = a
	myList.append(s)
for elem in myList:
	print(*elem)


def infinity(n, k, a):
	if k % 2 == 0:
		j = 0
	else:
		j = 1
	while j != 2:
		d = max(a)
		for i in range(n):
			a[i] = d - a[i]
		j += 1
	return a
n = int(input())
res = []
for i in range(n):
	a = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	res.append(infinity(a[0], a[1], arr))
for j in res:
	tmp3 = str(j).strip('[]').replace(',', '')
	print(tmp3)


def f():
	t = int(input())
	for _ in range(t):
		(n, k) = list(map(lambda x: int(x), input().split()))
		arr = list(map(lambda x: int(x), input().split()))
		if k == 0:
			arr = list(map(lambda x: str(x), arr))
			print(' '.join(arr))
			continue
		d = max(arr)
		d2 = min(arr)
		if k % 2 == 1:
			arr = list(map(lambda x: str(d - x), arr))
		else:
			arr = list(map(lambda x: str(x - d2), arr))
		print(' '.join(arr))
f()


for i in range(int(input())):
	(n, ar) = (list(map(int, input().split())), list(map(int, input().split())))
	max1 = max(ar)
	ar1 = [max1 - i for i in ar]
	max2 = max(ar1)
	ar2 = [max2 - i for i in ar1]
	if n[1] % 2 == 1:
		print(' '.join(list(map(str, ar1))))
	else:
		print(' '.join(list(map(str, ar2))))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	e = []
	f = []
	mx = max(a)
	for i in a:
		e.append(mx - i)
	mm = max(e)
	for i in e:
		f.append(mm - i)
	if k % 2 == 0:
		print(*f)
	else:
		print(*e)


from collections import Counter, defaultdict, deque
import sys
input = sys.stdin.readline

def solve():
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	if k % 2:
		d = max(a)
		ans = []
		for i in range(n):
			ans.append(d - a[i])
		print(*ans)
	else:
		d = max(a)
		ans = []
		for i in range(n):
			ans.append(d - a[i])
		d = max(ans)
		a = ans
		ans = []
		for i in range(n):
			ans.append(d - a[i])
		print(*ans)
tt = int(input())
for test in range(tt):
	solve()


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	m = max(l)
	x = [m - p for p in l]
	m = max(x)
	y = [m - p for p in x]
	x = [str(p) for p in x]
	y = [str(p) for p in y]
	if k % 2 == 0:
		print(' '.join(y))
	else:
		print(' '.join(x))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	mx = max(arr)
	for i in range(n):
		arr[i] = mx - arr[i]
	odd = arr.copy()
	mx = max(arr)
	for i in range(n):
		arr[i] = mx - arr[i]
	even = arr.copy()
	if k % 2 == 0:
		print(' '.join(map(str, even)))
	else:
		print(' '.join(map(str, odd)))


def get_result():
	(n, k) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	if k == 0:
		return k
	mx = max(l)
	for i in range(n):
		l[i] = mx - l[i]
	if k % 2 == 1:
		return l
	mx = max(l)
	for i in range(n):
		l[i] = mx - l[i]
	return l

def main():
	t = int(input())
	for i in range(t):
		for i in get_result():
			print(i, end=' ')
		print()
main()


n = int(input())
answer = []
for i in range(n):
	(p, k) = input().split()
	k = int(k)
	mas = [int(j) for j in input().split()]
	m = max(mas)
	mas1 = [m - j for j in mas]
	m = max(mas1)
	mas2 = [m - j for j in mas1]
	if k == 0:
		answer.append(mas.copy())
	elif k % 2 == 0:
		answer.append(mas2.copy())
	else:
		answer.append(mas1.copy())
	mas.clear()
	mas1.clear()
	mas2.clear()
for i in answer:
	for j in i:
		print(j, end=' ')
	print()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	x = []
	y = []
	a = max(l)
	for i in l:
		x.append(a - i)
	b = max(x)
	for i in x:
		y.append(b - i)
	if k % 2 == 1:
		print(*x)
	else:
		print(*y)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	li = [int(x) for x in input().split()]
	d = max(li)
	temp = float('-inf')
	for j in range(n):
		li[j] = d - li[j]
		temp = max(temp, li[j])
	if k % 2 == 0:
		for j in range(n):
			li[j] = temp - li[j]
		print(*li)
	else:
		print(*li)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if k % 2 == 1:
		dekho = max(a)
		for i in range(len(a)):
			print(dekho - a[i], end=' ')
	else:
		for _ in range(2):
			dekho = max(a)
			for i in range(len(a)):
				a[i] = dekho - a[i]
		for i in a:
			print(i, end=' ')
	print()


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	if k == 0:
		print(a)
	elif k % 2 != 0:
		m = max(a)
		for i in range(n):
			a[i] = m - a[i]
		print(' '.join(map(str, a)))
	else:
		for j in range(2):
			m = max(a)
			for i in range(n):
				a[i] = m - a[i]
		print(' '.join(map(str, a)))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()][:n]
	s = max(a)
	b = [s - j for j in a]
	y = max(b)
	c = [y - l for l in b]
	if k % 2 == 0:
		print(*c)
	else:
		print(*b)


T = int(input())
for _ in range(T):
	(n, k) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	_max = max(arr)
	for i in range(n):
		arr[i] = _max - arr[i]
	ans1 = list(arr)
	_max = max(arr)
	for i in range(n):
		arr[i] = _max - arr[i]
	ans2 = list(arr)
	if k % 2 == 1:
		print(' '.join(map(str, ans1)))
	else:
		print(' '.join(map(str, ans2)))


for u in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	m = max(l)
	d = []
	dd = []
	for i in range(n):
		d.append(m - l[i])
	p = max(d)
	for i in range(n):
		dd.append(p - d[i])
	if k % 2 == 0:
		print(*dd)
	else:
		print(*d)


t = int(input())
for i in range(t):
	(n, j) = list(map(int, input().split()))
	li = list(map(int, input().split()))
	d = max(li)
	while j > 0:
		no = 0
		h = 0
		for i in li:
			if i < 0:
				no = 1
			if i == 0:
				h = 1
		if no == 0 and h == 1 and (j % 2 == 0):
			break
		li = [d - k for k in li]
		d = max(li)
		j -= 1
	print(*li)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	mx = max(a)
	f = [mx - x for x in a]
	mx2 = max(f)
	s = [mx2 - x for x in f]
	if k % 2 == 0:
		print(*s)
	else:
		print(*f)


t = int(input())
while t > 0:
	s = input()
	(n, k) = (int(s.split(' ')[0]), int(s.split(' ')[1]))
	arr = input()
	arr = arr.split(' ')
	m = float('-inf')
	for i in range(len(arr)):
		arr[i] = int(arr[i])
		m = max(m, arr[i])
	mn = float('-inf')
	for i in range(len(arr)):
		arr[i] = m - arr[i]
		mn = max(arr[i], mn)
	odd = [None] * len(arr)
	for i in range(len(arr)):
		odd[i] = str(mn - arr[i])
		arr[i] = str(arr[i])
	k -= 1
	if k % 2 == 0:
		print(' '.join(arr))
	else:
		print(' '.join(odd))
	t -= 1


t = int(input())
for i in range(0, t):
	(m, n) = map(int, input().split())
	arr = list(map(int, input().strip().split()))[:m]
	x = max(arr)
	arr1 = []
	arr2 = []
	for j in range(0, m):
		y = x - arr[j]
		arr1.append(y)
	xx = max(arr1)
	for j in range(0, m):
		yy = xx - arr1[j]
		arr2.append(yy)
	if n == 0:
		print(*arr, sep=' ')
	elif n % 2 == 0:
		print(*arr2, sep=' ')
	else:
		print(*arr1, sep=' ')


for i in range(int(input())):
	(n, k) = map(int, input().split(' '))
	l = list(map(int, input().split(' ')))
	a = max(l)
	b = min(l)
	if k % 2 == 1:
		print(' '.join(map(str, [a - i for i in l])))
	else:
		print(' '.join(map(str, [i - b for i in l])))


def check(arr):
	for i in arr:
		if i < 0:
			return True
	return False
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	li = list(map(int, input().split()))
	if n == 1:
		print(0)
	elif check(li):
		if k % 2 == 0:
			for i in range(2):
				maxx = max(li)
				li = list(map(lambda x: maxx - x, li))
		else:
			maxx = max(li)
			li = list(map(lambda x: maxx - x, li))
		print(*li)
	else:
		for i in range(k):
			maxx = max(li)
			li = list(map(lambda x: maxx - x, li))
		print(*li)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	ma = max(a)
	if n == 1:
		print(0)
	elif k % 2 == 0:
		a = list(map(lambda x: ma - x, a))
		ma = max(a)
		a = list(map(lambda x: ma - x, a))
		print(*a)
	else:
		a = list(map(lambda x: ma - x, a))
		print(*a)


for _ in range(int(input())):
	(n, k) = (int(x) for x in input().split())
	l = [int(x) for x in input().split()]
	a = max(l)
	e = min(l)
	if k % 2 == 0:
		for i in range(len(l)):
			l[i] -= e
	else:
		for i in range(len(l)):
			l[i] = a - l[i]
	print(*l)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	for o in range(k % 2 | 2):
		m = max(a)
		for i in range(n):
			a[i] = m - a[i]
	for i in a:
		print(str(i), end=' ')
	print()


for i in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	max_l = max(arr)
	min_l = min(arr)
	if k & 1:
		arr = [max_l - ele for ele in arr]
	else:
		arr = [ele - min_l for ele in arr]
	print(*arr)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	t = [*map(int, input().split())]
	mx = max(t)
	for i in range(n):
		t[i] = mx - t[i]
	if k % 2 == 0:
		mx = max(t)
		for i in range(n):
			t[i] = mx - t[i]
	print(*t)


def printArray(A, n, K):
	minEle = 10 ** 9
	maxEle = -10 ** 9
	for i in range(n):
		minEle = min(minEle, A[i])
		maxEle = max(maxEle, A[i])
	if K != 0:
		if K % 2 == 1:
			for i in range(n):
				A[i] = maxEle - A[i]
		else:
			for i in range(n):
				A[i] = A[i] - minEle
	return A
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	if n == 1:
		print(0)
	else:
		print(*printArray(arr, n, k))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	x = 0
	if k % 2 == 0:
		x = 2
	else:
		x = 1
	for i in range(x):
		amax = max(a)
		a = [amax - j for j in a]
	print(' '.join(map(str, a)))


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left
from bisect import bisect_right

def L():
	return list(map(int, stdin.readline().split()))

def In():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())
P = 1000000007

def main():
	for t in range(I()):
		(n, k) = In()
		arr = L()
		if k % 2 == 0:
			for j in range(2):
				d = max(arr)
				for i in range(n):
					arr[i] = d - arr[i]
			print(*arr)
		else:
			d = max(arr)
			for i in range(n):
				arr[i] = d - arr[i]
			print(*arr)
main()


t = int(input())
while t > 0:
	(n, k) = [int(x) for x in input().split()]
	l = [int(x) for x in input().split()]
	if n == 1:
		print(0)
	else:
		m = -1000000000
		for i in l:
			if m < i:
				m = i
		for i in range(n):
			l[i] = m - l[i]
		if k % 2 != 0:
			for i in l:
				print(i, end=' ')
		else:
			m = -1000000000
			for i in l:
				if m < i:
					m = i
			for i in range(n):
				print(m - l[i], end=' ')
		print()
	t -= 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = [0] * n
	c = [0] * n
	maxi = max(a)
	for i in range(n):
		b[i] = maxi - a[i]
	maxi1 = max(b)
	for i in range(n):
		c[i] = maxi1 - b[i]
	if k % 2 == 0:
		print(*c)
	else:
		print(*b)


def iter(a, n):
	for i in range(n):
		d = max(a)
		for i in range(len(a)):
			a[i] = d - a[i]
	return a
t = int(input())
for i in range(t):
	(len_array, k) = [int(i) for i in input().split()]
	array = [int(i) for i in input().split()]
	(even, uneven) = (array.copy(), array.copy())
	even = iter(even, 1)
	uneven = iter(uneven, 2)
	if k == 0:
		print(*array)
	elif k % 2 == 0:
		print(*uneven)
	elif k % 2 == 1:
		print(*even)


def final_arr(arr, k):
	if len(arr) == 1:
		arr[0] = 0
	while 0 not in arr or min(arr) < 0:
		d = max(arr)
		for i in range(len(arr)):
			arr[i] = d - arr[i]
		k -= 1
	if k % 2:
		d = max(arr)
		for i in range(len(arr)):
			arr[i] = d - arr[i]
	return arr
t = int(input())
for _ in range(t):
	nk = input().split()
	n = int(nk[0])
	k = int(nk[1])
	arr = list(map(int, input().split()))
	result = final_arr(arr, k)
	print(*result, sep=' ')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	w = list(map(int, input().split()))
	x = max(w)
	new1 = []
	for i in range(n):
		new1.append(x - w[i])
	x = max(new1)
	new2 = []
	for i in range(n):
		new2.append(str(x - new1[i]))
	for i in range(n):
		new1[i] = str(new1[i])
	if m % 2 == 0:
		print(' '.join(new2))
	else:
		print(' '.join(new1))


for _ in range(int(input())):
	(n, k) = [int(s) for s in input().split()]
	l = [int(s) for s in input().split()]
	w = max(l)
	l = [w - l[i] for i in range(n)]
	if k == 1:
		print(*l)
	else:
		k -= 1
		if k % 2 == 0:
			print(*l)
		else:
			w = max(l)
			l = [w - l[i] for i in range(n)]
			print(*l)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	maxelement = max(arr)
	if k % 2 == 0:
		arr = [maxelement - x for x in arr]
		maxelement = max(arr)
		arr = [maxelement - x for x in arr]
	else:
		arr = [maxelement - x for x in arr]
	print(' '.join(map(str, arr)))


for t in range(int(input())):
	a = input().split()
	(n, k) = (int(a[0]), int(a[1]))
	a = [int(i) for i in input().split()]
	x = max(a)
	b = [x - i for i in a]
	y = max(b)
	c = [y - i for i in b]
	if k % 2 == 1:
		print(*b, sep=' ')
	else:
		print(*c, end=' ')


def getArray(arr, k, n):
	if k % 2 == 1:
		val = max(arr)
		for i in range(n):
			arr[i] = val - arr[i]
	else:
		val = min(arr)
		for i in range(n):
			arr[i] -= val
	return arr
t = int(input())
for i in range(t):
	(n, k) = tuple(map(int, input().split()))
	arr = list(map(int, input().split()))
	rel = getArray(arr, k, n)
	print(' '.join(list(map(str, rel))))


import sys
input = sys.stdin.readline

def main(n, k, lst):
	lst1 = []
	(maxx, minn) = (max(lst), min(lst))
	if k % 2:
		for i in lst:
			lst1.append(maxx - i)
		return lst1
	else:
		for i in lst:
			lst1.append(i - minn)
		return lst1
for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	lst = list(map(int, input().split()))
	print(' '.join(list(map(str, main(n, k, lst)))))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	f = [0] * n
	s = [0] * n
	t = [0] * n
	if k > 3:
		m = max(a)
		for j in range(n):
			f[j] = m - a[j]
		m = max(f)
		for j in range(n):
			s[j] = m - f[j]
		m = max(s)
		for j in range(n):
			t[j] = m - s[j]
		if k % 2 == 0:
			for j in s:
				print(j, end=' ')
			print()
		else:
			for j in t:
				print(j, end=' ')
			print()
	else:
		for qw in range(k):
			m = max(a)
			for j in range(n):
				a[j] = m - a[j]
		for j in a:
			print(j, end=' ')
		print()


import sys

def main():
	input = sys.stdin.readline
	print = sys.stdout.write
	t = int(input())
	for i1 in [0] * t:
		(n, k) = map(int, input().split())
		nums = list(map(int, input().split()))
		current_max = max(nums)
		for i in range(n):
			nums[i] = current_max - nums[i]
		if k % 2 == 1:
			print(' '.join((str(x) for x in nums)))
			print('\n')
		else:
			new_max = max(nums)
			for j in range(n):
				nums[j] = new_max - nums[j]
			print(' '.join((str(x) for x in nums)))
			print('\n')
main()


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	ai = list(map(int, input().split()))
	flag = 0
	for i in range(n):
		if ai[i] <= 0:
			flag = 1
			break
	maxn = max(ai)
	for j in range(n):
		ai[j] = maxn - ai[j]
	maxn = max(ai)
	for j in range(n):
		if k % 2 == 0:
			print(maxn - ai[j], end=' ')
		else:
			print(ai[j], end=' ')
	print()


def list_add(in1, in2):
	return list(map(lambda x, y: x - y, in1, in2))
t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	if k % 2 == 1:
		mm = max(a)
		a_max = [mm for i in range(n)]
		arr = list_add(a_max, a)
	else:
		mm = max(a)
		a_max = [mm for i in range(n)]
		a = list_add(a_max, a)
		mm = max(a)
		a_max = [mm for i in range(n)]
		arr = list_add(a_max, a)
	if n == 1:
		print(0)
	else:
		print(*arr)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	ans = arr[:]
	if k % 2 == 0:
		d = min(arr)
		for i in range(n):
			ans[i] = ans[i] - d
	else:
		d = max(arr)
		for i in range(n):
			ans[i] = d - ans[i]
	print(*ans)


t = int(input())
ans = ''
for j in range(t):
	nk = input().split()
	n = int(nk[0])
	k = int(nk[1])
	a = [int(i) for i in input().split()]
	d = a[0]
	a1 = ''
	for i in range(n):
		d = max(d, a[i])
	d1 = d - a[0]
	for i in range(n):
		d1 = max(d1, d - a[i])
	if k % 2 == 1:
		for i in range(n):
			a1 += str(d - a[i]) + ' '
	else:
		for i in range(n):
			a1 += str(d1 - d + a[i]) + ' '
	ans += a1 + '\n'
print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().strip().split()))[:n]
	arr1 = []
	s = max(arr)
	for num in arr:
		arr1.append(s - num)
	arr2 = []
	s = max(arr1)
	for num in arr1:
		arr2.append(s - num)
	if k % 2 == 1:
		for num in arr1:
			print(num, end=' ')
	else:
		for num in arr2:
			print(num, end=' ')
	print()


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	mx = max(a)
	for i in range(n):
		a[i] = mx - a[i]
	k -= 1
	mx = max(a)
	if k & 1 == 0:
		print(*a)
	else:
		for i in range(n):
			a[i] = mx - a[i]
		print(*a)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	if set(a) == 1:
		for i in range(n):
			print('0', end=' ')
		print(end='')
	else:
		d = max(a)
		for i in range(n):
			a[i] = d - a[i]
		if k % 2 == 0:
			d = max(a)
			for i in range(n):
				a[i] = d - a[i]
		for i in a:
			print(i, end=' ')
		print('')


t = int(input())
c = []
for i in range(t):
	(n, k) = input().split()
	(n, k) = (int(n), int(k))
	a = [int(u) for u in input().split()]
	d = max(a)
	b = []
	if k == 0:
		c.append(a)
	elif k % 2 == 0:
		for x in a:
			b.append(d - x)
		d = max(b)
		for j in range(n):
			b[j] = d - b[j]
	else:
		for x in a:
			b.append(d - x)
	c.append(b)
for k in c:
	for x in k:
		print(x, end=' ')
	print()


t = int(input())
for kk in range(t):
	(num, k) = map(int, input().split())
	l = [int(j) for j in input().split()]
	m = max(l)
	for i in range(num):
		l[i] = m - l[i]
	if k % 2 == 0:
		m = max(l)
		for i in range(num):
			l[i] = m - l[i]
	print(*l)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	m = max(a)
	for j in range(n):
		a[j] = m - a[j]
	m = max(a)
	if k % 2 == 1:
		print(*a)
	for j in range(n):
		a[j] = m - a[j]
	if k % 2 == 0:
		print(*a)


import math
import collections
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect_left as bsl
from bisect import bisect_right as bsr
import heapq as hq
setrecursionlimit(2 ** 20)
t = 1
t = int(stdin.readline())
for _ in range(t):
	(n, k) = list(map(int, stdin.readline().rstrip().split()))
	a = list(map(int, stdin.readline().rstrip().split()))
	mi = min(a)
	mx = max(a)
	if k % 2 == 1:
		for i in a:
			print(mx - i, end=' ')
		print()
	else:
		for i in a:
			print(i - mi, end=' ')
		print()


t = int(input())
for tc in range(t):
	(n, k) = map(int, input().split())
	li = list(map(int, input().split()))
	li1 = []
	li2 = []
	p = max(li[:])
	for i in li:
		li1.append(p - i)
	l = max(li1[:])
	for i in li1:
		li2.append(l - i)
	if k == 0:
		for i in li:
			print(i)
	elif k % 2 != 0:
		for i in li1:
			print(i)
	else:
		for i in li2:
			print(i)


for _ in range(int(input())):
	X = list(map(int, input().split()))
	Numbers = list(map(int, input().split()))
	Answers = []
	for i in range(2):
		Max = max(Numbers)
		for j in range(X[0]):
			Numbers[j] = Max - Numbers[j]
		Answers.append(Numbers[:])
	print(*Answers[(X[1] + 1) % 2])


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	m1 = max(a)
	a1 = [m1 - a[i] for i in range(n)]
	m2 = max(a1)
	if k % 2:
		print(*a1)
	else:
		print(*[m2 - a1[i] for i in range(n)])


def cal(li, n, k):
	c = 0
	if k != 0:
		m = max(li)
		for i in range(n):
			li[i] = m - li[i]
	if k % 2 == 0:
		m = max(li)
		for i in range(n):
			li[i] = m - li[i]
	for i in range(n):
		print(li[i], end=' ')
t = int(input())
while t > 0:
	(n, k) = [int(ele) for ele in input().split()]
	li = [int(ele) for ele in input().split()]
	cal(li, n, k)
	t = t - 1


T = int(input())
for i in range(T):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	d = max(arr)
	for i in range(n):
		arr[i] = d - arr[i]
	if k == 1:
		for i in range(n):
			print(arr[i], end=' ')
	else:
		arr2 = []
		d = max(arr)
		for i in range(n):
			arr2.append(d - arr[i])
		if k % 2 != 0:
			for i in range(n):
				print(arr[i], end=' ')
		else:
			for i in range(n):
				print(arr2[i], end=' ')
	print()


n = int(input())
for i in range(n):
	l = list(map(int, input().split()))
	k = list(map(int, input().split()))
	s = max(k)
	for p in range(l[0]):
		k[p] = s - k[p]
	if l[1] % 2 == 0:
		s = max(k)
		for p in range(l[0]):
			k[p] = s - k[p]
	for p in range(l[0]):
		print(k[p], end=' ')
	print()


import sys
t = int(input())
answers = []
for i in range(t):
	(n, k) = [int(j) for j in input().split()]
	a = [int(j) for j in input().split()]
	a_max = max(a)
	a_min = min(a)
	if k % 2 == 0:
		print(' '.join([str(j - a_min) for j in a]))
	else:
		print(' '.join([str(a_max - j) for j in a]))


t = int(input())
while t:
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	mini = min(a)
	maxi = max(a)
	if k % 2 == 0:
		for ele in a:
			print(ele - mini, end=' ')
	else:
		for ele in a:
			print(maxi - ele, end=' ')
	print()
	t -= 1


def solve():
	(n, m) = map(int, input().split())
	lst = list(map(int, input().split()))
	m %= 2
	for i in range(m + 2):
		k = max(lst)
		lst = [k - i for i in lst]
	print(*lst)
for i in range(int(input())):
	solve()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ar = [int(x) for x in input().split()]
	temp = []
	d = max(ar)
	temp = [int(d - x) for x in ar]
	k = k - 1
	if k % 2 == 0:
		print(*temp)
	else:
		final = max(temp)
		print(*[int(final - y) for y in temp])


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
import random
sys.setrecursionlimit(10 ** 6)
from queue import PriorityQueue
from collections import Counter as cc
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
from itertools import permutations
from math import factorial as f

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p
import sys
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	z = max(l)
	for i in range(n):
		l[i] = z - l[i]
	k -= 1
	ha = l.copy()
	z = max(l)
	for i in range(n):
		ha[i] = z - l[i]
	if k % 2 == 0:
		print(*l)
	else:
		print(*ha)


for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	lst = [int(i) for i in input().split()]
	k -= 1
	m = max(lst)
	for i in range(n):
		lst[i] = m - lst[i]
	m = max(lst)
	if k % 2:
		for i in range(n):
			print(m - lst[i], end=' ')
		print()
	else:
		for i in range(n):
			print(lst[i], end=' ')
		print()


t = int(input())
for aa in range(t):
	(n, k) = [int(xx) for xx in input().split()]
	a = [int(xx) for xx in input().split()]
	w = max(a)
	for i in range(n):
		a[i] = w - a[i]
	k -= 1
	w = max(a)
	if k % 2 == 0:
		for j in a:
			print(j, end=' ')
		print('')
	else:
		for j in a:
			print(w - j, end=' ')
		print('')


t = int(input())
for _ in range(t):
	x = list(map(int, input().split()))
	(n, k) = (x[0], x[1])
	l = list(map(int, input().split()))
	d = max(l)
	p = []
	q = []
	for i in range(n):
		p.append(d - l[i])
	y = max(p)
	for i in range(n):
		q.append(y - p[i])
	if k % 2 == 1:
		for i in p:
			print(i, end=' ')
		print()
	else:
		for i in q:
			print(i, end=' ')
		print()


from os import path
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input().rstrip()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('a')
file = 1

def solve():
	for _ in range(ii()):
		(n, k) = mi()
		a = li()
		k1 = k
		mx = max(a)
		mnx = min(a)
		x = mx
		(mnx, mx) = (0, mx - mnx)
		k -= 1
		if k & 1:
			x = mx - x
		for i in range(n):
			if k1 & 1:
				print(x - a[i], end=' ')
			else:
				print(x + a[i], end=' ')
		print()
if file:
	if path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	else:
		input = sys.stdin.readline
solve()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if k == 1:
		mx = max(a)
		a = [mx - x for x in a]
	elif k >= 2:
		mn = min(a)
		a = [x - mn for x in a]
		if k % 2 == 1:
			mx = max(a)
			a = [mx - x for x in a]
	print(*a)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	m1 = max(a)
	m2 = min(a)
	m = m1 - m2
	for j in range(n):
		a[j] = m1 - a[j]
	if (k - 1) % 2 == 0:
		for j in a:
			print(j, end=' ')
	else:
		for j in a:
			print(m - j, end=' ')
	print()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = [int(j) for j in input().split()]
	ma = max(arr)
	for i in range(n):
		arr[i] = ma - arr[i]
	k -= 1
	if k % 2 == 0:
		print(*arr)
	else:
		ma = max(arr)
		for i in range(n):
			arr[i] = ma - arr[i]
		print(*arr)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if n == 1:
		print(0, end=' ')
	elif k % 2 != 0:
		d = max(a)
		for i in range(n):
			print(d - a[i], end=' ')
	else:
		e = max(a)
		d = min(a)
		for i in a:
			print(i - d, end=' ')
	print()


from math import *
from cmath import *
from itertools import *
from decimal import *
from fractions import *
from sys import *
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	if k > 1:
		k = 2 + int(k % 2)
	while k:
		k -= 1
		x = max(a)
		for y in range(0, n):
			a[y] = x - a[y]
	for x in a:
		print(x, end=' ')
	print()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	mx = max(arr)
	arr = [mx - i for i in arr]
	if k == 1:
		print(*arr)
		continue
	mx2 = max(arr)
	arr2 = [mx2 - i for i in arr]
	mx3 = max(arr2)
	arr3 = [mx3 - i for i in arr2]
	if k % 2 == 0:
		print(*arr2)
	else:
		print(*arr3)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for j in range(int(input())):
	(n, k) = map(int, input().split())
	vals = list(map(int, input().split()))
	maxy = max(vals)
	v1 = [maxy - k for k in vals]
	maxy1 = max(v1)
	v2 = [maxy1 - k for k in v1]
	if k % 2 == 1:
		print(*v1)
	else:
		print(*v2)


import sys

def main():
	t = int(sys.stdin.readline())
	for _ in range(t):
		(n, k) = [int(x) for x in sys.stdin.readline().split(' ')]
		a = [int(x) for x in sys.stdin.readline().split(' ')]
		mx = max(a)
		a = [mx - x for x in a]
		newMX = max(a)
		if k % 2 == 0:
			a = [newMX - x for x in a]
		print(' '.join((str(x) for x in a)))
main()


for i in range(int(input())):
	(x, k) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	req = max(l)
	for j in range(x):
		l[j] = req - l[j]
	ans1 = list(map(str, l))
	ans1 = ' '.join(ans1)
	req = max(l)
	for j in range(x):
		l[j] = req - l[j]
	ans2 = list(map(str, l))
	ans2 = ' '.join(ans2)
	if k % 2 == 0:
		print(ans2)
	else:
		print(ans1)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	m = max(l)
	for i in range(len(l)):
		l[i] = m - l[i]
	if k % 2 == 0:
		m = max(l)
		for i in range(len(l)):
			l[i] = m - l[i]
	for i in l:
		print(i, end=' ')
	print('')


for testcases in range(int(input())):
	(num, ope) = map(int, input().split())
	l = list(map(int, input().split()))
	maxi = max(l)
	mini = min(l)
	if ope & 1 == 0:
		for i in range(num):
			l[i] -= mini
	else:
		for i in range(num):
			l[i] = maxi - l[i]
	print(*l)


def final(n, k, a):
	d = max(a)
	for j in range(n):
		a[j] = d - a[j]
	if k % 2 != 0:
		print(*a)
	else:
		d = max(a)
		for u in range(n):
			a[u] = d - a[u]
		print(*a)
t = int(input())
for w in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	final(n, k, a)


t = int(input())
while t > 0:
	(n, m) = map(int, input().split())
	lst = list(map(int, input().split()))
	if m % 2 == 0:
		lst1 = max(lst)
		for i in range(2):
			lst = list(map(lambda x: lst1 - x, lst))
			lst1 = max(lst)
		print(*lst)
	else:
		lst1 = max(lst)
		for i in range(1):
			lst = list(map(lambda x: lst1 - x, lst))
			lst1 = max(lst)
		print(*lst)
	t -= 1


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(t,) = I()
for _ in range(t):
	(n, k) = I()
	l = I()
	mx = max(l)
	for i in range(n):
		l[i] = mx - l[i]
	if k % 2:
		print(*l)
	else:
		mx = max(l)
		for i in range(n):
			l[i] = mx - l[i]
		print(*l)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = [int(v) for v in input().split()]
	p = min(a)
	q = max(a)
	for j in range(n):
		a[j] = q - a[j]
	if k % 2 == 0:
		for j in range(n):
			a[j] = q - p - a[j]
	print(' '.join(map(str, a)))


T = int(input())
infinityClockArrs = []

def infinityClock(arr, k):
	sortedArr = sorted(arr)
	if k % 2 == 0:
		d = sortedArr[0]
		for idx in range(len(arr)):
			arr[idx] = arr[idx] - d
	else:
		d = sortedArr[len(sortedArr) - 1]
		for idx in range(len(arr)):
			arr[idx] = d - arr[idx]
	return list(map(str, arr))
for t in range(T):
	arrAndOperationSize = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	infinityClockArrs.append(infinityClock(arr, arrAndOperationSize[1]))
for infinityClockArr in infinityClockArrs:
	print(' '.join(infinityClockArr))


import sys
LI = lambda : list(map(int, sys.stdin.readline().strip('\n').split()))
MI = lambda : map(int, sys.stdin.readline().strip('\n').split())
SI = lambda : sys.stdin.readline().strip('\n')
II = lambda : int(sys.stdin.readline().strip('\n'))
for _ in range(II()):
	(n, k) = MI()
	a = LI()
	k -= 1
	d = max(a)
	for i in range(n):
		a[i] = d - a[i]
	if k % 2:
		d = max(a)
		for i in range(n):
			a[i] = d - a[i]
	print(*a)


t = int(input())
for _ in range(t):
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	initial_max = max(a)
	initial_min = min(a)
	if k % 2 == 1:
		print(' '.join((str(initial_max - a_i) for a_i in a)))
	elif k % 2 == 0:
		print(' '.join((str(a_i - initial_min) for a_i in a)))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	x = max(l)
	for i in range(n):
		l[i] = x - l[i]
	l1 = l.copy()
	x = max(l1)
	for i in range(n):
		l1[i] = x - l1[i]
	if k % 2 == 0:
		print(*l1)
	else:
		print(*l)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	c = 2
	aa = max(a)
	for x in range(n):
		a[x] = aa - a[x]
	k = k - 1
	if k == 0:
		print(*a)
	elif k % 2 == 0:
		print(*a)
	else:
		aa = max(a)
		for x in range(n):
			a[x] = aa - a[x]
		print(*a)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	x = 12903810927839
	if k >= 2:
		if k % 2 == 0:
			for i in range(2):
				d = max(a)
				for j in range(n):
					a[j] = d - a[j]
			print(*a)
		elif k % 2 != 0:
			d = max(a)
			z = []
			for i in a:
				z.append(d - i)
			print(*z)
	else:
		d = max(a)
		z = []
		for i in a:
			z.append(d - i)
		print(*z)


for _ in range(int(input())):
	cnt1 = []
	cnt2 = []
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	mx2 = int(-100000000000.0)
	mx = max(arr)
	for i in range(n):
		cnt1.append(mx - arr[i])
		mx2 = max(cnt1[i], mx2)
	for i in range(n):
		cnt2.append(mx2 - cnt1[i])
	if k & 1:
		print(*cnt1)
	else:
		print(*cnt2)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	if k == 0 or k == 1 or k == 2:
		for i in range(k):
			d = max(l)
			l = list(map(lambda x: d - x, l))
		print(*l)
	else:
		d = max(l)
		lk1 = list(map(lambda x: d - x, l))
		d1 = max(lk1)
		lk2 = list(map(lambda x: d1 - x, lk1))
		if k & 1 == 0:
			print(*lk2)
		else:
			print(*lk1)


from collections import Counter, defaultdict
from sys import stdin, stdout
input = stdin.readline
I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
for _ in range(I()):
	(n, k) = M()
	a = LI()
	d = max(a)
	b = []
	c = []
	for i in range(n):
		b += [d - a[i]]
	d = max(b)
	for i in range(n):
		c += [d - b[i]]
	if k % 2:
		print(*b)
	else:
		print(*c)


def tran(nk, arr):
	k = nk[1]
	an = []
	if k == 1:
		ma = max(arr)
		for i in arr:
			an.append(ma - i)
		return an
	elif k % 2 == 0:
		an2 = []
		ma = max(arr)
		for i in arr:
			an.append(ma - i)
		ma2 = max(an)
		for i in an:
			an2.append(ma2 - i)
		return an2
	else:
		an2 = []
		an3 = []
		ma = max(arr)
		for i in arr:
			an.append(ma - i)
		ma2 = max(an)
		for i in an:
			an2.append(ma2 - i)
		ma3 = max(an2)
		for j in an2:
			an3.append(ma3 - j)
		return an3
t = int(input())
ans = []
for i in range(t):
	nk = list(map(int, input().rstrip().split()))
	arr = list(map(int, input().rstrip().split()))
	r = tran(nk, arr)
	ans.append(r)
for i in ans:
	print(*i)


t = int(input())
for z in range(t):
	n = input()
	lst = n.split()
	k = int(lst[1])
	arr = input()
	lst = arr.split()
	val = []
	for i in range(len(lst)):
		ele = int(lst[i])
		val.append(ele)
	md = k % 2
	if md == 1:
		maxval = max(val)
		for j in range(len(val)):
			val[j] = maxval - val[j]
	else:
		maxval = max(val)
		for j in range(len(val)):
			val[j] = maxval - val[j]
		maxval = max(val)
		for j in range(len(val)):
			val[j] = maxval - val[j]
	for i in range(len(val) - 1):
		print(val[i], end=' ')
	print(val[len(val) - 1])


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	if n == 1:
		print(0)
	else:
		(times, z) = (2, [])
		if k & 1:
			times = 1
		for j in range(times):
			x = max(l)
			for i in range(n):
				l[i] = x - l[i]
		print(*l)


try:
	t = int(input())
	while t != 0:
		(n, k) = map(int, input().split())
		arr = list(map(int, input().split()))
		if k == 1:
			maxnum = max(arr)
			for i in range(n):
				arr[i] = maxnum - arr[i]
			print(*arr)
		else:
			maxnum = max(arr)
			for i in range(n):
				arr[i] = maxnum - arr[i]
			if k % 2 != 0:
				print(*arr)
			else:
				maxnum = max(arr)
				for i in range(n):
					arr[i] = maxnum - arr[i]
				print(*arr)
		t = t - 1
except EOFError:
	print(' ')


from sys import stdin
input = lambda : stdin.readline().strip()
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	m = min(a)
	M = max(a)
	if k == 0:
		print(*a)
	elif k % 2 == 0:
		for i in range(n):
			a[i] = a[i] - m
	else:
		for i in range(n):
			a[i] = M - a[i]
	print(*a)


for t in range(int(input())):
	(n, k) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	m = max(a)
	n = min(a)
	if k % 2 != 0:
		for b in a:
			print(m - b, end=' ')
	else:
		for b in a:
			print(b - n, end=' ')
	print(' ')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [*map(int, input().split())]
	(o, e) = ([], [])
	m = max(a)
	for i in range(n):
		o.append(m - a[i])
	m = max(o)
	for i in range(n):
		e.append(m - o[i])
	if k & 1:
		print(*o)
	else:
		print(*e)


def Max(a):
	t = max(a)
	for i in a:
		print(t - i, end=' ')
	print()

def Min(a):
	t = min(a)
	for i in a:
		print(i - t, end=' ')
	print()
for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	if k % 2 == 1:
		Max(a)
	else:
		Min(a)


import math
from collections import *
import sys
from functools import reduce
import time
from itertools import groupby

def input():
	return sys.stdin.readline()

def get_ints():
	return map(int, input().strip().split())

def get_list():
	return list(get_ints())

def get_string():
	return list(input().strip().split())

def printxsp(*args):
	return print(*args, end='')

def printsp(*args):
	return print(*args, end=' ')
for _test_ in range(int(input())):
	(n, k) = get_ints()
	li = get_list()
	for h in range(2):
		d = max(li)
		for i in range(n):
			li[i] = d - li[i]
		if h == 0:
			li0 = li.copy()
		else:
			li1 = li.copy()
	if k & 1:
		print(*li0)
	else:
		print(*li1)


t = int(input())
for k in range(t):
	(n, k) = (int(i) for i in input().split())
	a = [int(i) for i in input().split()]
	m = max(a)
	a = [m - i for i in a]
	if k % 2 == 0:
		m = max(a)
		a = [m - i for i in a]
	print(' '.join([str(i) for i in a]))


ls = []
t = int(input())
for z in range(t):
	nk = list(map(int, input().rstrip().split()))
	n = nk[0]
	k = nk[1]
	if k > 3:
		if k % 2 == 0:
			k = 2
		else:
			k = 1
	a = list(map(int, input().rstrip().split()))
	for i in range(k):
		temp = max(a)
		for j in range(n):
			a[j] = temp - a[j]
	st = ''
	for i in a:
		st += str(i) + ' '
	ls.append(st.rstrip())
for i in ls:
	print(i)