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.io.*;
import java.util.*;
public class Main {

    public static void main(String args[]) {
        FastIO io = new FastIO();
        int T = io.nextInt();
        for (int t = 1; t <= T; t++) {
            int N = io.nextInt();
            long K = io.nextLong();
            int[] arr = new int[N];
            int max = Integer.MIN_VALUE;
            for (int i = 0; i < N; i++) {
                arr[i] = io.nextInt();
                max = Math.max(arr[i], max);
            }

            int max2 = Integer.MIN_VALUE;
            for (int i = 0; i < N; i++) {
                arr[i] = max - arr[i];
                max2 = Math.max(max2, arr[i]);
            }

            if (K % 2 == 1) {
                for (int i = 0; i < N; i++) {
                    io.printls(arr[i]);
                }
                io.write((byte) 10);
            } else {
                for (int i = 0; i < N; i++) {
                    arr[i] = max2 - arr[i];
                }

                for (int i = 0; i < N; i++) {
                    io.printls(arr[i]);
                }
                io.write((byte) 10);
            }

        }


        io.flushbuffer();
    }

    private static class FastIO {
        private static final int DEFAULT_BUFFER_SIZE = 65536;
        private static final int DEFAULT_LONG_SIZE = 20;
        private static final int DEFAULT_INT_SIZE = 11;
        private static final int DEFAULT_LINE_SIZE = 30;
        private static final int EOF = -1;

        private static final byte ASCII_n = 10;
        private static final byte ASCII_r = 13;
        private static final byte ASCII_space = 32;
        private static final byte ASCII_minus = 45;
        private static final byte ASCII_0 = 48;
        private static final byte ASCII_9 = 57;

        private final DataInputStream din;
        private final DataOutputStream dout;

        private byte[] inbuffer;
        private int inbufferpointer, bytesread;
        private byte[] outbuffer;
        private int outbufferpointer;

        private byte[] bytebuffer;
        private char[] charbuffer;

        private FastIO(int inbuffersize, int outbuffersize) {
            this.din = new DataInputStream(System.in);
            this.dout = new DataOutputStream(System.out);

            this.inbuffer = new byte[inbuffersize];
            this.inbufferpointer = 0;
            this.bytesread = 0;
            this.outbuffer = new byte[outbuffersize];
            this.outbufferpointer = 0;

            this.bytebuffer = new byte[DEFAULT_LONG_SIZE];
            this.charbuffer = new char[DEFAULT_LINE_SIZE];
        }

        private FastIO() {
            this(DEFAULT_BUFFER_SIZE, DEFAULT_BUFFER_SIZE);
        }

        private FastIO(int buffersize) {
            this(buffersize, buffersize);
        }

        private byte read() {
            if (inbufferpointer == bytesread)
                fillbuffer();
            return bytesread == EOF ? EOF : inbuffer[inbufferpointer++];
        }

        private void fillbuffer() {
            try {
                bytesread = din.read(inbuffer, inbufferpointer = 0, inbuffer.length);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }

        private void write(byte b) {
            if (outbufferpointer == outbuffer.length)
                flushbuffer();
            outbuffer[outbufferpointer++] = b;
        }

        private void flushbuffer() {
            if (outbufferpointer != 0) {
                try {
                    dout.write(outbuffer, 0, outbufferpointer);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
                outbufferpointer = 0;
            }
        }

        private char nextChar() {
            byte b;
            while (isSpace(b = read()))
                ;
            return (char) b;
        }

        private String next() {
            byte b;
            while (isSpace(b = read())) {
            }
            int index = 0;
            do {
                charbuffer[index++] = (char) b;
            } while (!isSpace(b = read()));
            return new String(charbuffer, 0, index);
        }

        private String nextLine() {
            byte b;
            int index = 0;
            while (!isLine(b = read()))
                charbuffer[index++] = (char) b;
            return new String(charbuffer, 0, index);
        }

        private int nextInt() {
            byte b;
            while(isSpace(b = read()))
                ;
            boolean negative = false;
            if (b == '-') {
                negative = true;
                b = read();
            }
            int result = b - '0';
            while (isDigit(b = read()))
                result = result * 10 + b - '0';
            return negative ? -result : result;
        }

        private long nextLong() {
            byte b;
            while(isSpace(b = read()))
                ;
            boolean negative = false;
            if (b == '-') {
                negative = true;
                b = read();
            }
            long result = b - '0';
            while (isDigit(b = read()))
                result = result * 10 + b - '0';
            return negative ? -result : result;
        }

        private float nextFloat() {
            byte b;
            while (isSpace(b = read()))
                ;
            boolean negative = false;
            if (b == ASCII_minus) {
                negative = true;
                b = read();
            }
            float f = 0;
            do {
                f = f * 10 + b - ASCII_0;
            } while (isDigit(b = read()));
            int d = 1;
            b = read();
            do {
                f = f * 10 + b - ASCII_0;
                d = d * 10;
            } while (isDigit(b = read()));
            return f / d;

        }

        private void print(char c) {
            write((byte) c);
        }

        private void print(char[] c) {
            for (int i = 0; i < c.length; i++) {
                write((byte) c[i]);
            }
        }

        private void print(String s) {
            for (int i = 0; i < s.length(); i++) {
                write((byte) s.charAt(i));
            }
        }

        private void println(int i) {
            if (i == 0) {
                write(ASCII_0);
            } else {
                if (i < 0) {
                    write(ASCII_minus);
                    i = -i;
                }
                int index = 0;
                while (i > 0) {
                    bytebuffer[index++] = (byte) ((i % 10) + ASCII_0);
                    i /= 10;
                }
                while (index-- > 0) {
                    write(bytebuffer[index]);
                }
            }
            write(ASCII_n);
        }

        private void printls(int i) {
            if (i == 0) {
                write(ASCII_0);
            } else {
                if (i < 0) {
                    write(ASCII_minus);
                    i = -i;
                }
                int index = 0;
                while (i > 0) {
                    bytebuffer[index++] = (byte) ((i % 10) + ASCII_0);
                    i /= 10;
                }
                while (index-- > 0) {
                    write(bytebuffer[index]);
                }
            }
            write(ASCII_space);
        }

        private void print(long l) {
            if (l == 0) {
                write(ASCII_0);
            } else {
                if (l < 0) {
                    write(ASCII_minus);
                    l = -l;
                }
                int index = 0;
                while (l > 0) {
                    bytebuffer[index++] = (byte) ((l % 10) + ASCII_0);
                    l /= 10;
                }
                while (index-- > 0) {
                    write(bytebuffer[index]);
                }
            }
        }

        private boolean isLine(byte b) {
            return b == ASCII_r || b == ASCII_n || b == EOF;
        }

        private boolean isSpace(byte b) {
            return b <= ASCII_space && b >= 0;
        }

        private boolean isDigit(byte b) {
            return b >= ASCII_0 && b <= ASCII_9;
        }
    }
}