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

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

import java.util.*;


import static java.lang.Math.*;

import java.io.DataInputStream; 
import java.io.FileInputStream; 
import java.io.IOException; 
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.math.BigInteger; 

public class Main 
{ 

	static int mod = 1000000007;
	static int MOD = 1000000007;
	static int temp = 998244353;
	static final long M = (int)1e9+7;

	
	static class Pair implements Comparable<Pair>
	{
		int first, second;
		public Pair(int aa, int bb)
		{
			first = aa; second = bb;
		}
		public int compareTo(Pair p)
		{
//			if(a == p.a) return b - p.b;
//			return a - p.a;
			if(first == p.first) return second - p.second;
			return first - p.first;
		}
	}
	
	/*
	 * IO FOR 2D GRID IN JAVA
	 * char[][] arr = new char[n][m]; //grid in Q.
			
			for(int i = 0;i<n;i++)
			{
				char[] nowLine = sc.next().toCharArray();
				for(int j = 0;j<m;j++)
				{
					arr[i][j] = nowLine[i];
				}
			}
	 * */
	
	static class Reader 
	{ 
		final private int BUFFER_SIZE = 1 << 16; 
		private DataInputStream din; 
		private byte[] buffer; 
		private int bufferPointer, bytesRead; 

		public Reader() 
		{ 
			din = new DataInputStream(System.in); 
			buffer = new byte[BUFFER_SIZE]; 
			bufferPointer = bytesRead = 0; 
		} 

		public Reader(String file_name) throws IOException 
		{ 
			din = new DataInputStream(new FileInputStream(file_name)); 
			buffer = new byte[BUFFER_SIZE]; 
			bufferPointer = bytesRead = 0; 
		} 

		public String next() throws IOException 
		{ 
			byte[] buf = new byte[64]; // line length 
			int cnt = 0, c; 
			while ((c = read()) != -1) 
			{ 
				if (c == '\n') 
					break; 
				buf[cnt++] = (byte) c; 
			} 
			return new String(buf, 0, cnt); 
		} 
		
		public int nextInt() throws IOException 
		{ 
			int ret = 0; 
			byte c = read(); 
			while (c <= ' ') 
				c = read(); 
			boolean neg = (c == '-'); 
			if (neg) 
				c = read(); 
			do
			{ 
				ret = ret * 10 + c - '0'; 
			} while ((c = read()) >= '0' && c <= '9'); 

			if (neg) 
				return -ret; 
			return ret; 
		}
		int[] readArray(int n) throws IOException {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}

		public long nextLong() throws IOException 
		{ 
			long ret = 0; 
			byte c = read(); 
			while (c <= ' ') 
				c = read(); 
			boolean neg = (c == '-'); 
			if (neg) 
				c = read(); 
			do { 
				ret = ret * 10 + c - '0'; 
			} 
			while ((c = read()) >= '0' && c <= '9'); 
			if (neg) 
				return -ret; 
			return ret; 
		} 

		public double nextDouble() throws IOException 
		{ 
			double ret = 0, div = 1; 
			byte c = read(); 
			while (c <= ' ') 
				c = read(); 
			boolean neg = (c == '-'); 
			if (neg) 
				c = read(); 

			do { 
				ret = ret * 10 + c - '0'; 
			} 
			while ((c = read()) >= '0' && c <= '9'); 

			if (c == '.') 
			{ 
				while ((c = read()) >= '0' && c <= '9') 
				{ 
					ret += (c - '0') / (div *= 10); 
				} 
			} 

			if (neg) 
				return -ret; 
			return ret; 
		} 

		private void fillBuffer() throws IOException 
		{ 
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE); 
			if (bytesRead == -1) 
				buffer[0] = -1; 
		} 

		private byte read() throws IOException 
		{ 
			if (bufferPointer == bytesRead) 
				fillBuffer(); 
			return buffer[bufferPointer++]; 
		} 

		public void close() throws IOException 
		{ 
			if (din == null) 
				return; 
			din.close(); 
		}

		public BigInteger nextBigInteger() {
			// TODO Auto-generated method stub
			return null;
		}

	}

	
	public static boolean isPrime(long n) {
		if(n == 1)
		{
			return false;
		}
		for(long i = 2;i*i<=n;i++)
		{
			if(n%i == 0)
			{
				return false;
			}
		}
		return true;
	}
	
	
	
	public static int gcd(int a, int b)
	{
		if(b == 0)
		 return a;
		
		else
		return gcd(b,a%b);
	}
	
	public static long LongGCD(long a, long b)
	{
		if(b == 0)
			 return a;
			
			else
			return LongGCD(b,a%b);
	}


	public static int lcm(int a, int b)
    {
        return (a / gcd(a, b)) * b;
    }
	
	public static int phi(int n)  //euler totient function
    { 
        int result = 1; 
        for (int i = 2; i < n; i++) 
            if (gcd(i, n) == 1) 
                result++; 
        return result; 
    }
	
	    
	public static int[] computePrefix(int arr[], int n)
	{
		int[] prefix = new int[n];
		prefix[0] = arr[0];
		for(int i = 1;i<n;i++)
		{
			prefix[i] = prefix[i-1]+arr[i];
		}
		
		return prefix;
	}
	
	
	public static int fastPow(int x, int n) //include mod at each step if asked and in args of fn too
	{
		if(n == 0)
			return 1;
		else if(n%2 == 0)
			return fastPow(x*x,n/2);
		else
			return x*fastPow(x*x,(n-1)/2);
	}
	
	
	   public static int power(int x, int y, int p)
	    {
	 
	        int res = 1;
	 
	        x = x % p;
	 
	        while (y > 0) {
	            if (y % 2 == 1)
	                res = (res * x) % p;
	 
	            y = y >> 1; 
	            x = (x * x) % p;
	        }
	 
	        return res;
	    }

		public static int LowerBound(int a[], int x) {
			  int l=-1,r=a.length;
			  while(l+1<r) {
			    int m=(l+r)>>>1;
			    if(a[m]>=x) r=m;
			    else l=m;
			  }
			  return r;
			}
		
		
		public static int UpperBound(int a[], int x) {
		    int l=-1,r=a.length;
		    while(l+1<r) {
		       int m=(l+r)>>>1;
		       if(a[m]<=x) l=m;
		       else r=m;
		    }
		    return l+1;
		}
		
		public static void Sort(int[] a) {
			List<Integer> l=new ArrayList<>();
			for (int i:a) l.add(i);
			Collections.sort(l);
			//Collections.reverse(l);  //Use to Sort decreasingly 
			for (int i=0; i<a.length; i++) a[i]=l.get(i);
		}
		
		//MODULO OPS for addition and multiplication 
		
		   public static long perfomMod(long x){
		        return ((x%M + M)%M);
		    }
		   public static long addMod(long a, long  b){
		        return perfomMod(perfomMod(a)+perfomMod(b));
		    }
		   public static long mulMod(long  a, long b){
		        return perfomMod(perfomMod(a)*perfomMod(b));
		   }
		  
		   public static void perform(int[] arr)
		   {
			   int ms = arr[0];
			   for(int i : arr)
			   {
				   ms = max(ms,i);
			   }
			   int n  =arr.length;
			   for(int i = 0;i<n;i++)
			   {
				   arr[i] = ms - arr[i];
			   }
		   }
		  
		   
		public static void main(String[] args) throws IOException 
		{ 
			Reader sc = new Reader();
			PrintWriter out = new PrintWriter(System.out);
			
			int t = sc.nextInt();
			while(t-- > 0)
			{
				int n = sc.nextInt(),k = sc.nextInt();
				k = k-1;
				int[] arr = sc.readArray(n);
				perform(arr);
				for(int i = 0;i<k%2;i++)
				{
					perform(arr);
				}
				for(int i : arr)
				{
					System.out.print(i + " ");
				}
				System.out.println();
			}
			
			out.close();
		}
}


 