import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.*;

public class B {
	public void run() throws Exception {
		FastScanner sc = new FastScanner();

		int test = sc.nextInt();
		outer:
		for (int loop = 0; loop<test; loop++) {
			int n = sc.nextInt();
			int k = sc.nextInt();
			int[] arr = new int[n];
			int max = Integer.MIN_VALUE;
			int min = Integer.MAX_VALUE;
			for (int i  =0; i<n; i++) {
				arr[i] = sc.nextInt();
				max = Math.max(max, arr[i]);
				min = Math.min(min, arr[i]);
			}
			if (k == 1) {
				for (int i = 0; i<n; i++) {
					arr[i] = max-arr[i];
				}
			}
			else if (min<0) {
				max+=Math.abs(min);
				for (int i = 0; i<n; i++) {
					arr[i]+=Math.abs(min);
				}
				if (k%2 == 1) {
					for (int i = 0; i<n; i++) {
						arr[i] = max-arr[i];
					}
				}
			}
			else {
				if (k%2 == 0) {
					for (int i = 0; i<n; i++) {
						arr[i] = max-arr[i];
					}
				}
				else {
					int max1 = Integer.MIN_VALUE;
					for (int i = 0; i<n; i++) {
						arr[i] = max-arr[i];
						max1 = Math.max(arr[i], max1);
					}
					for (int i = 0; i<n; i++) {
						arr[i] = max1-arr[i];
					}
				}
			}
			for (int i =0; i<n; i++) {
				System.out.print(arr[i] + " ");
			}
			System.out.println();
		}
	}
	//SSR <3 2020
	public class Pair implements Comparable<Pair>{
		int num, times;
		public Pair(int a, int b) {
			num = a;
			times = b;
		}
		public int compareTo(Pair a) {
			if (num == a.num) return times-a.times;
			return num-a.num;
		}
		public String toString() {
			return num + " " + times;
		}
	}
	public int[] shuffleArray(int[] arr) {
        int n = arr.length;
        Random rnd = new Random();
        for(int i=0; i<n; ++i){
        	int tmp = arr[i];
            int randomPos = i + rnd.nextInt(n-i);
            arr[i] = arr[randomPos];
            arr[randomPos] = tmp;
        }
        return arr;
	}
	public boolean isPrime(long n) {
		for (long i = 2; i<=Math.sqrt(n); i++) {
			if (n%i == 0) return false;
		}
		return true;
	}
	public static long gcd(long a, long b)   {
		if (a == b) return a;
		if (a > b) return gcd(a-b, b);
		return gcd(a, b-a);
    }
	static class FastScanner {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public FastScanner() {
			reader = new BufferedReader(new InputStreamReader(System.in), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}

	}
	public static void main (String[] args) throws Exception {
		new B().run();
	}
}


import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.*;

public class B {
	public void run() throws Exception {
		FastScanner sc = new FastScanner();

		int test = sc.nextInt();
		outer:
		for (int loop = 0; loop<test; loop++) {
			int n = sc.nextInt();
			int k = sc.nextInt();
			long[] arr = new long[n];
			long max = Long.MIN_VALUE;
			for (int i  =0; i<n; i++) {
				arr[i] = sc.nextLong();
				max = Math.max(max, arr[i]);
			}
			long max1 = Integer.MIN_VALUE;
			for (int i = 0; i<n; i++) {
				arr[i] = max-arr[i];
				max1 = Math.max(arr[i], max1);
			}
			if (k%2 == 0) {
				for (int i = 0; i<n; i++) {
					arr[i] = max1-arr[i];
				}
			}
			for (int i =0; i<n; i++) {
				System.out.print(arr[i] + " ");
			}
			System.out.println();
		}
	}
	//SSR <3 2020
	public class Pair implements Comparable<Pair>{
		int num, times;
		public Pair(int a, int b) {
			num = a;
			times = b;
		}
		public int compareTo(Pair a) {
			if (num == a.num) return times-a.times;
			return num-a.num;
		}
		public String toString() {
			return num + " " + times;
		}
	}
	public int[] shuffleArray(int[] arr) {
        int n = arr.length;
        Random rnd = new Random();
        for(int i=0; i<n; ++i){
        	int tmp = arr[i];
            int randomPos = i + rnd.nextInt(n-i);
            arr[i] = arr[randomPos];
            arr[randomPos] = tmp;
        }
        return arr;
	}
	public boolean isPrime(long n) {
		for (long i = 2; i<=Math.sqrt(n); i++) {
			if (n%i == 0) return false;
		}
		return true;
	}
	public static long gcd(long a, long b)   {
		if (a == b) return a;
		if (a > b) return gcd(a-b, b);
		return gcd(a, b-a);
    }
	static class FastScanner {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public FastScanner() {
			reader = new BufferedReader(new InputStreamReader(System.in), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}

	}
	public static void main (String[] args) throws Exception {
		new B().run();
	}
}


import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.*;

public class B {
	public void run() throws Exception {
		FastScanner sc = new FastScanner();

		int test = sc.nextInt();
		for (int loop = 0; loop<test; loop++) {
			int n = sc.nextInt();
			long k = sc.nextLong()%2;
			long[] arr = new long[n];
			long max = Long.MIN_VALUE;
			for (int i  =0; i<n; i++) {
				arr[i] = sc.nextLong();
				max = Math.max(max, arr[i]);
			}
			long max1 = Long.MIN_VALUE;
			for (int i = 0; i<n; i++) {
				arr[i] = max-arr[i];
				max1 = Math.max(arr[i], max1);
			}
			if (k%2 == 0) {
				for (int i = 0; i<n; i++) {
					arr[i] = max1-arr[i];
				}
			}
			for (int i =0; i<n; i++) {
				System.out.print(arr[i] + " ");
			}
			System.out.println();
		}
	}
	//SSR <3 2020
	public class Pair implements Comparable<Pair>{
		int num, times;
		public Pair(int a, int b) {
			num = a;
			times = b;
		}
		public int compareTo(Pair a) {
			if (num == a.num) return times-a.times;
			return num-a.num;
		}
		public String toString() {
			return num + " " + times;
		}
	}
	public int[] shuffleArray(int[] arr) {
        int n = arr.length;
        Random rnd = new Random();
        for(int i=0; i<n; ++i){
        	int tmp = arr[i];
            int randomPos = i + rnd.nextInt(n-i);
            arr[i] = arr[randomPos];
            arr[randomPos] = tmp;
        }
        return arr;
	}
	public boolean isPrime(long n) {
		for (long i = 2; i<=Math.sqrt(n); i++) {
			if (n%i == 0) return false;
		}
		return true;
	}
	public static long gcd(long a, long b)   {
		if (a == b) return a;
		if (a > b) return gcd(a-b, b);
		return gcd(a, b-a);
    }
	static class FastScanner {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public FastScanner() {
			reader = new BufferedReader(new InputStreamReader(System.in), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}

	}
	public static void main (String[] args) throws Exception {
		new B().run();
	}
}


import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.*;

public class B {
	public void run() throws Exception {
		FastScanner sc = new FastScanner();

		int test = sc.nextInt();
		outer:
		for (int loop = 0; loop<test; loop++) {
			int n = sc.nextInt();
			int k = sc.nextInt();
			int[] arr = new int[n];
			int max = Integer.MIN_VALUE;
			int min = Integer.MAX_VALUE;
			for (int i  =0; i<n; i++) {
				arr[i] = sc.nextInt();
				max = Math.max(max, arr[i]);
				min = Math.min(min, arr[i]);
			}
			if (min<0 && k>=2) {
				max+=Math.abs(min);
				for (int i = 0; i<n; i++) {
					arr[i]+=Math.abs(min);
				}
				if (k%2 == 1) {
					for (int i = 0; i<n; i++) {
						arr[i] = max-arr[i];
					}

				}
			}
			else if (k == 1) {
				for (int i = 0; i<n; i++) {
					arr[i] = max-arr[i];
				}
			}
			else {
				if (k%2 == 0) {
					for (int i = 0; i<n; i++) {
						arr[i] = max-arr[i];
					}
				}
				else {
					int max1 = Integer.MAX_VALUE;
					for (int i = 0; i<n; i++) {
						arr[i] = max-arr[i];
						max1 = Math.max(arr[i], max1);
					}
					for (int i = 0; i<n; i++) {
						arr[i] = max1-arr[i];
					}
				}
			}
			for (int i =0; i<n; i++) {
				System.out.print(arr[i] + " ");
			}
			System.out.println();
		}
	}
	//SSR <3 2020
	public class Pair implements Comparable<Pair>{
		int num, times;
		public Pair(int a, int b) {
			num = a;
			times = b;
		}
		public int compareTo(Pair a) {
			if (num == a.num) return times-a.times;
			return num-a.num;
		}
		public String toString() {
			return num + " " + times;
		}
	}
	public int[] shuffleArray(int[] arr) {
        int n = arr.length;
        Random rnd = new Random();
        for(int i=0; i<n; ++i){
        	int tmp = arr[i];
            int randomPos = i + rnd.nextInt(n-i);
            arr[i] = arr[randomPos];
            arr[randomPos] = tmp;
        }
        return arr;
	}
	public boolean isPrime(long n) {
		for (long i = 2; i<=Math.sqrt(n); i++) {
			if (n%i == 0) return false;
		}
		return true;
	}
	public static long gcd(long a, long b)   {
		if (a == b) return a;
		if (a > b) return gcd(a-b, b);
		return gcd(a, b-a);
    }
	static class FastScanner {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public FastScanner() {
			reader = new BufferedReader(new InputStreamReader(System.in), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}

	}
	public static void main (String[] args) throws Exception {
		new B().run();
	}
}


import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
 {
	public static void main (String[] args) throws IOException
	 {
	 //code
	 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	 StringBuilder sb=new StringBuilder();
	 int t=Integer.parseInt(br.readLine());
	 while(t-->0)
	    {
	       String s[]=br.readLine().split(" ");
	       int n=Integer.parseInt(s[0]),k=Integer.parseInt(s[1]);

	       s=br.readLine().split(" ");

	       int a[]=new int[n];
	       int max=Integer.MIN_VALUE,max2=Integer.MIN_VALUE;

	       for(int i=0;i<n;i++)
	       {
	           a[i]=Integer.parseInt(s[i]);
	           max=Math.max(max,a[i]);
	       }

    	       for(int i=0;i<n;i++)
    	       {
    	           a[i]=max-a[i];
    	           max2=Math.max(max2,a[i]);
    	       }
	       if(k%2==0 && k!=0)
	       {
    	       for(int i=0;i<n;i++)
    	       {
    	           a[i]=max2-a[i];
    	       }
	       }

	        for(int i=0;i<n;i++)
	        {
	            sb.append(a[i]).append(" ");
	        }

	        sb.append("\n");

	    }

	    System.out.print(sb);

	 }

}


import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
 {
	public static void main (String[] args) throws IOException
	 {
	 //code
	 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	 StringBuilder sb=new StringBuilder();
	 int t=Integer.parseInt(br.readLine());
	 while(t-->0)
	    {
	       String s[]=br.readLine().split(" ");
	       int n=Integer.parseInt(s[0]),k=Integer.parseInt(s[1]);

	       s=br.readLine().split(" ");

	       int a[]=new int[n];
	       int max=Integer.MIN_VALUE-1,max2=Integer.MIN_VALUE-1;

	       for(int i=0;i<n;i++)
	       {
	           a[i]=Integer.parseInt(s[i]);
	           max=Math.max(max,a[i]);
	       }
	       if(k!=0)
	       {
        	       for(int i=0;i<n;i++)
        	       {
        	           a[i]=max-a[i];
        	           max2=Math.max(max2,a[i]);
        	       }
    	       if(k%2==0)
    	       {
        	       for(int i=0;i<n;i++)
        	       {
        	           a[i]=max2-a[i];
        	       }
    	       }
	       }

	        for(int i=0;i<n;i++)
	        {
	            sb.append(a[i]).append(" ");
	        }

	        sb.append("\n");

	    }

	    System.out.print(sb);

	 }

}


import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
 {
	public static void main (String[] args) throws IOException
	 {
	 //code
	 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	 StringBuilder sb=new StringBuilder();
	 int t=Integer.parseInt(br.readLine());
	 while(t-->0)
	    {
	       String s[]=br.readLine().split(" ");
	       int n=Integer.parseInt(s[0]);long k=Long.parseLong(s[1]);

	       s=br.readLine().split(" ");

	       long a[]=new long[n];
	       long max=Long.MIN_VALUE,max2=Long.MIN_VALUE;

	       for(int i=0;i<n;i++)
	       {
	           a[i]=Long.parseLong(s[i]);
	           max=Math.max(max,a[i]);
	       }
	       if(k!=0)
	       {
        	       for(int i=0;i<n;i++)
        	       {
        	           a[i]=max-a[i];
        	           max2=Math.max(max2,a[i]);
        	       }
    	       if(k%2==0)
    	       {
        	       for(int i=0;i<n;i++)
        	       {
        	           a[i]=max2-a[i];
        	       }
    	       }
	       }

	        for(int i=0;i<n;i++)
	        {
	            sb.append(a[i]).append(" ");
	        }

	        sb.append("\n");

	    }

	    System.out.print(sb);

	 }

}


import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
 {
	public static void main (String[] args) throws IOException
	 {
	 //code
	 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	 StringBuilder sb=new StringBuilder();
	 int t=Integer.parseInt(br.readLine());
	 while(t-->0)
	    {
	       String s[]=br.readLine().split(" ");
	       int n=Integer.parseInt(s[0]),k=Integer.parseInt(s[1]);

	       s=br.readLine().split(" ");

	       int a[]=new int[n];
	       int max=Integer.MIN_VALUE,max2=Integer.MIN_VALUE;

	       for(int i=0;i<n;i++)
	       {
	           a[i]=Integer.parseInt(s[i]);
	           max=Math.max(max,a[i]);
	       }
	       if(k!=0)
	       {
    	       for(int i=0;i<n;i++)
    	       {
    	           a[i]=max-a[i];
    	           max2=Math.max(max2,a[i]);
    	       }
	       }
	       if(k%2==0 && k!=0)
	       {
    	       for(int i=0;i<n;i++)
    	       {
    	           a[i]=max2-a[i];
    	       }
	       }

	        for(int i=0;i<n;i++)
	        {
	            sb.append(a[i]).append(" ");
	        }

	        sb.append("\n");

	    }

	    System.out.print(sb);

	 }

}


import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
 {
	public static void main (String[] args) throws IOException
	 {
	 //code
	 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	 StringBuilder sb=new StringBuilder();
	 int t=Integer.parseInt(br.readLine());
	 while(t-->0)
	    {
	       String s[]=br.readLine().split(" ");
	       int n=Integer.parseInt(s[0]),k=Integer.parseInt(s[1]);

	       s=br.readLine().split(" ");

	       long a[]=new long[n];
	       long max=Long.MIN_VALUE,max2=Long.MIN_VALUE;

	       for(int i=0;i<n;i++)
	       {
	           a[i]=Long.parseLong(s[i]);
	           max=Math.max(max,a[i]);
	       }
	       if(k!=0)
	       {
        	       for(int i=0;i<n;i++)
        	       {
        	           a[i]=max-a[i];
        	           max2=Math.max(max2,a[i]);
        	       }
    	       if(k%2==0)
    	       {
        	       for(int i=0;i<n;i++)
        	       {
        	           a[i]=max2-a[i];
        	       }
    	       }
	       }

	        for(int i=0;i<n;i++)
	        {
	            sb.append(a[i]).append(" ");
	        }

	        sb.append("\n");

	    }

	    System.out.print(sb);

	 }

}


import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
 {
	public static void main (String[] args) throws IOException
	 {
	 //code
	 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	 StringBuilder sb=new StringBuilder();
	 int t=Integer.parseInt(br.readLine());
	 while(t-->0)
	    {
	       String s[]=br.readLine().split(" ");
	       int n=Integer.parseInt(s[0]),k=Integer.parseInt(s[1]);

	       s=br.readLine().split(" ");

	       ArrayList<Integer> al=new ArrayList<>();

	       for(int i=0;i<n;i++)
	       {
	           al.add(Integer.parseInt(s[i]));
	       }

	       if(k%2==0)
	        k=2;
	       else
	        k=1;
	        for(int i=0;i<k;i++)
	        {
	            int max=Collections.max(al);
    	        for(int j=0;j<n;j++)
            	      {
            	           al.set(j,max-al.get(j));
            	      }
	        }

	        for(int i=0;i<n;i++)
	        {
	            sb.append(al.get(i)).append(" ");
	        }

	        sb.append("\n");

	    }

	    System.out.print(sb);

	 }

}


import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
 {
	public static void main (String[] args) throws IOException
	 {
	 //code
	 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	 StringBuilder sb=new StringBuilder();
	 int t=Integer.parseInt(br.readLine());
	 while(t-->0)
	    {
	       String s[]=br.readLine().split(" ");
	       int n=Integer.parseInt(s[0]),k=Integer.parseInt(s[1]);

	       s=br.readLine().split(" ");
	       PriorityQueue<Integer> p1 =
             new PriorityQueue<Integer>(Collections.reverseOrder());
	      // ArrayList<Integer> al=new ArrayList<>();
	       int a[]=new int[n];
	       for(int i=0;i<n;i++)
	       {
	           //al.add(Integer.parseInt(s[i]));
	           a[i]=Integer.parseInt(s[i]);
	           p1.add(a[i]);
	       }
	       if(k!=0)
	       {
    	       int max=p1.poll();
    	       for(int i=0;i<n;i++)
    	       {
    	           //al.add(Integer.parseInt(s[i]));
    	          // a[i]=Integer.parseInt(s[i]);
    	           a[i]=max-a[i];
    	       }
	       }
	       if(k%2==0 && k!=0)
	       {
	            PriorityQueue<Integer> p2 =
             new PriorityQueue<Integer>(Collections.reverseOrder());
    	       for(int i=0;i<n;i++)
    	       {

    	           p2.add(a[i]);
    	       }
    	       int max2=p2.poll();
    	       for(int i=0;i<n;i++)
    	       {
    	           a[i]=max2-a[i];
    	       }
	       }

	        for(int i=0;i<n;i++)
	        {
	            sb.append(a[i]).append(" ");
	        }

	        sb.append("\n");

	    }

	    System.out.print(sb);

	 }

}


import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
 {
	public static void main (String[] args) throws IOException
	 {
	 //code
	 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	 StringBuilder sb=new StringBuilder();
	 int t=Integer.parseInt(br.readLine());
	 while(t-->0)
	    {
	       String s[]=br.readLine().split(" ");
	       int n=Integer.parseInt(s[0]),k=Integer.parseInt(s[1]);

	       s=br.readLine().split(" ");

	       int a[]=new int[n];
	       int max=Integer.MIN_VALUE,max2=Integer.MIN_VALUE;

	       for(int i=0;i<n;i++)
	       {
	           a[i]=Integer.parseInt(s[i]);
	           max=Math.max(max,a[i]);
	       }
	       if(k!=0)
	       {
        	       for(int i=0;i<n;i++)
        	       {
        	           a[i]=max-a[i];
        	           max2=Math.max(max2,a[i]);
        	       }
    	       if(k%2==0)
    	       {
        	       for(int i=0;i<n;i++)
        	       {
        	           a[i]=max2-a[i];
        	       }
    	       }
	       }

	        for(int i=0;i<n;i++)
	        {
	            sb.append(a[i]).append(" ");
	        }

	        sb.append("\n");

	    }

	    System.out.print(sb);

	 }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static class Node {
        int i, val;

        public Node(int i, int val) {
            this.i = i;
            this.val = val;
        }
    }

    public static void main(String[] args) {
        FastReader fastReader = new FastReader();
        int T = fastReader.nextInt();
        for (int t = 0; t < T; t++) {

            int N = fastReader.nextInt();
            int K = fastReader.nextInt();
            int[] A = new int[N];
            int max = Integer.MIN_VALUE;
            for (int i = 0; i < N; i++) {
                A[i] = fastReader.nextInt();
                max = Math.max(A[i], max);
            }
            for (int i = 0; i < N; i++) {
                A[i] = max - A[i];
            }
            K--;
            if (K % 2 == 0) {
                for (int i = 0; i < N; i++) {
                    System.out.print(A[i] + " ");
                }
                System.out.println();
            } else {
                for (int i = 0; i < N; i += 2) {
                    if (i + 1 < N) {
                        int temp = A[i];
                        A[i] = A[i + 1];
                        A[i + 1] = temp;
                    }
                }
                for (int i = 0; i < N; i++) {
                    System.out.print(A[i] + " ");
                }
                System.out.println();
            }

        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static class Node {
        int i, val;

        public Node(int i, int val) {
            this.i = i;
            this.val = val;
        }
    }

    public static void main(String[] args) {
        FastReader fastReader = new FastReader();
        int T = fastReader.nextInt();
        for (int t = 0; t < T; t++) {

            int N = fastReader.nextInt();
            int K = fastReader.nextInt();
            int[] A = new int[N];
            int max = Integer.MIN_VALUE;
            for (int i = 0; i < N; i++) {
                A[i] = fastReader.nextInt();
                max = Math.max(A[i], max);
            }

            for (int i = 0; i < N; i++) {
                A[i] = max - A[i];
            }

            if (K % 2 == 1) {
                for (int i = 0; i < N; i++) {
                    System.out.print(A[i] + " ");
                }
                System.out.println();
            } else {
                for (int i = 0; i < N; i += 2) {
                    if (i + 1 < N) {
                        int temp = A[i];
                        A[i] = A[i + 1];
                        A[i + 1] = temp;
                    }
                }
                for (int i = 0; i < N; i++) {
                    System.out.print(A[i] + " ");
                }
                System.out.println();
            }

        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static class Node {
        int i, val;

        public Node(int i, int val) {
            this.i = i;
            this.val = val;
        }
    }

    public static void main(String[] args) {
        FastReader fastReader = new FastReader();
        int T = fastReader.nextInt();
        for (int t = 0; t < T; t++) {

            int N = fastReader.nextInt();
            long K = fastReader.nextLong();
            long[] A = new long[N];
            long max = Long.MIN_VALUE;
            for (int i = 0; i < N; i++) {
                A[i] = fastReader.nextLong();
                max = Math.max(A[i], max);
            }
            for (int i = 0; i < N; i++) {
                A[i] = max - A[i];
            }
            K--;
            if (K % 2 == 0) {
                for (int i = 0; i < N; i++) {
                    System.out.print(A[i] + " ");
                }
            } else {
                for (int i = 0; i < N; i += 2) {
                    if (i + 1 < N) {
                        long temp = A[i];
                        A[i] = A[i + 1];
                        A[i + 1] = temp;
                    }
                }
                for (int i = 0; i < N; i++) {
                    System.out.print(A[i] + " ");
                }
            }
            System.out.println();

        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static class Node {
        int i, val;

        public Node(int i, int val) {
            this.i = i;
            this.val = val;
        }
    }

    public static void main(String[] args) {
        FastReader fastReader = new FastReader();
        int T = fastReader.nextInt();
        for (int t = 0; t < T; t++) {

            int N = fastReader.nextInt();
            long K = fastReader.nextLong();
            long[] A = new long[N];
            long[] A1 = new long[N];
            long[] A2 = new long[N];

            long max = Long.MIN_VALUE;
            for (int i = 0; i < N; i++) {
                A[i] = fastReader.nextLong();
                max = Math.max(A[i], max);
            }

            long max2 = Long.MIN_VALUE;
            for (int i = 0; i < N; i++) {
                A1[i] = max - A[i];
                max2 = Math.max(max2, A1[i]);
            }

            for (int i = 0; i < N; i++) {
                A2[i] = max2 - A1[i];
            }

            if (K % 2 == 1) {
                for (int i = 0; i < N; i++) {
                    System.out.print(A1[i] + " ");
                }
            } else {
                for (int i = 0; i < N; i++) {
                    System.out.print(A2[i] + " ");
                }
            }
            System.out.println();

        }
    }
}

//10
//        4 5
//        3 -4 6 -7
//        4 4
//        3 -4 6 -7


import java.io.*;
import java.util.*;
import java.util.concurrent.ArrayBlockingQueue;
import java.lang.*;
import java.math.*;
import java.text.DecimalFormat;
import java.lang.reflect.Array;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
public class Codeforces{
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static long MOD = (long)(1e9+7);
	//static long MOD = 998244353;
	static FastReader sc = new FastReader();
	static int pInf = Integer.MAX_VALUE;
	static int nInf = Integer.MIN_VALUE;
	public static void main(String[] args){
		int test = 1;
		test = sc.nextInt();
		while(test-->0){
			int n = sc.nextInt();
			int k = sc.nextInt();
			long[] a = new long[n];
			long max = Long.MIN_VALUE;
			for(int i = 0; i < n; i++) {
				a[i] = sc.nextLong();
				max = Math.max(max, a[i]);
			}
			long[] odd = new long[n];
			for(int i = 0; i < n; i++) {
				odd[i] = max-a[i];
			}
			if((k&1)==1) {
				for(int i = 0; i < n; i++) {
					out.print(odd[i]+" ");
				}
				out.println();
			}
			else {
				for(int i = n-1; i >=0 ; i--) {
					out.print(odd[i]+" ");
				}
				out.println();
			}
		}
		out.close();
	}
	public static long mul(long a, long b){
	    return ((a%MOD)*(b%MOD))%MOD;
	}
	public static long add(long a, long b){
	    return ((a%MOD)+(b%MOD))%MOD;
	}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Integer.lowestOneBit(i)   Equals k where k is the position of the first one in the binary
//Integer.highestOneBit(i)  Equals k where k is the position of the last one in the binary
//Integer.bitCount(i)       returns the number of one-bits
//Collections.sort(A,(p1,p2)->(int)(p2.x-p1.x)) To sort ArrayList in descending order wrt values of x.
//            Arrays.parallelSort(a,new Comparator<TPair>() {
//      		public int compare(TPair a,TPair b) {
//        			if(a.y==b.y) return a.x-b.x;
//        			return b.y-a.y;
//        		}
//        	});
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//PrimeFactors
    public static ArrayList<Long> primeFactors(long n) {
        ArrayList<Long> arr = new ArrayList<>();
        if (n % 2 == 0)
            arr.add((long) 2);
        while (n % 2 == 0)
            n /= 2;
        for (long i = 3; i <= Math.sqrt(n); i += 2) {
            int flag = 0;
            while (n % i == 0) {
                n /= i;
                flag = 1;
            }
            if (flag == 1)
                arr.add(i);
        }
        if (n > 2)
            arr.add(n);
        return arr;
    }
//Pair Class
	static class Pair implements Comparable<Pair>{
		int x;
		int y;
		public Pair(int x, int y) {
			this.x = x;
			this.y = y;
		}
		@Override
		public int compareTo(Pair o) {
			if(this.x==o.x){
			    return (this.y-o.y);
			}
			return (this.x-o.x);
		}
	}
	static class TPair{
		int min;
		int max;
		int c;
		public TPair(int min, int max, int c) {
			this.min = min;
			this.max = max;
			this.c = c;
		}
	}
//nCr
	static long ncr(long n, long k) {
        long ret = 1;
        for (long x = n; x > n - k; x--) {
            ret *= x;
            ret /= (n - x + 1);
        }

        return ret;
    }
	static long finextDoubleMMI_fermat(long n,int M)
    {
        return fastExpo(n,M-2);
    }

    static long nCrModPFermat(int n, int r, int p)
    {
        if (r == 0)
            return 1;
        long[] fac = new long[n+1];
        fac[0] = 1;
        for (int i = 1 ;i <= n; i++)
            fac[i] = fac[i-1] * i % p;
        return (fac[n]* finextDoubleMMI_fermat(fac[r], p)% p * finextDoubleMMI_fermat(fac[n-r], p) % p) % p;
    }
//Merge Sort
	static void merge(long arr[], int l, int m, int r)
    {
        // Find sizes of two subarrays to be merged
        int n1 = m - l + 1;
        int n2 = r - m;

        /* Create temp arrays */
        long L[] = new long [n1];
        long R[] = new long [n2];

        /*Copy data to temp arrays*/
        for (int i=0; i<n1; ++i)
            L[i] = arr[l + i];
        for (int j=0; j<n2; ++j)
            R[j] = arr[m + 1+ j];

        /* Merge the temp arrays */

        // Initial indexes of first and second subarrays
        int i = 0, j = 0;

        // Initial index of merged subarry array
        int k = l;
        while (i < n1 && j < n2)
        {
            if (L[i] <= R[j])
            {
                arr[k] = L[i];
                i++;
            }
            else
            {
                arr[k] = R[j];
                j++;
            }
            k++;
        }

        /* Copy remaining elements of L[] if any */
        while (i < n1)
        {
            arr[k] = L[i];
            i++;
            k++;
        }

        /* Copy remaining elements of R[] if any */
        while (j < n2)
        {
            arr[k] = R[j];
            j++;
            k++;
        }
    }

    // Main function that sorts arr[l..r] using
    // merge()
    static void sort(long arr[], int l, int r)
    {
        if (l < r)
        {
            // Find the middle point
            int m = (l+r)/2;

            // Sort first and second halves
            sort(arr, l, m);
            sort(arr , m+1, r);

            // Merge the sorted halves
            merge(arr, l, m, r);
        }
    }
//Brian Kernighan’s Algorithm
    static long countSetBits(long n){
        if(n==0) return 0;
        return 1+countSetBits(n&(n-1));
    }
//Factorial
    static long factorial(long n){
        if(n==1) return 1;
        if(n==2) return 2;
        if(n==3) return 6;
        return n*factorial(n-1);
    }
//Euclidean Algorithm
    static long gcd(long A,long B){
        if(B==0) return A;
        return gcd(B,A%B);
    }
//Modular Exponentiation
    static long fastExpo(long x,long n){
        if(n==0) return 1;
        if((n&1)==0) return fastExpo((x*x)%MOD,n/2)%MOD;
        return ((x%MOD)*fastExpo((x*x)%MOD,(n-1)/2))%MOD;
    }
//AKS Algorithm
    static boolean isPrime(long n){
        if(n<=1) return false;
        if(n<=3) return true;
        if(n%2==0 || n%3==0) return false;
        for(int i=5;i<=Math.sqrt(n);i+=6)
            if(n%i==0 || n%(i+2)==0) return false;
        return true;
    }
//Reverse an array
    static <T> void reverse(T arr[],int l,int r){
    	Collections.reverse(Arrays.asList(arr).subList(l, r));
    }
//Sieve of eratosthenes
    static int[] findPrimes(int n){
        boolean isPrime[]=new boolean[n+1];
        ArrayList<Integer> a=new ArrayList<>();
        int result[];
        Arrays.fill(isPrime,true);
        isPrime[0]=false;
        isPrime[1]=false;
        for(int i=2;i*i<=n;++i){
            if(isPrime[i]==true){
                for(int j=i*i;j<=n;j+=i) isPrime[j]=false;
            }
        }
        for(int i=0;i<=n;i++) if(isPrime[i]==true) a.add(i);
        result=new int[a.size()];
        for(int i=0;i<a.size();i++) result[i]=a.get(i);
        return result;

    }
//Indivisual factors of all nos till n
    static ArrayList<Integer>[] indiFactors(int n){
    	ArrayList<Integer>[] A = new ArrayList[n+1];
    	for(int i = 0; i <= n; i++) {
    		A[i] = new ArrayList<>();
    	}
    	int[] sieve = new int[n+1];
    	for(int i=2;i<=n;i++) {
       		if(sieve[i]==0) {
       			for(int j=i;j<=n;j+=i) if(sieve[j]==0) {
       				//sieve[j]=i;
       				A[i].add(j);
       			}
       		}
       	}
    	return A;
    }
//Segmented Sieve
    static boolean[] segmentedSieve(long l, long r){
    	boolean[] segSieve = new boolean[(int)(r-l+1)];
    	Arrays.fill(segSieve, true);
    	int[] prePrimes = findPrimes((int)Math.sqrt(r));
    	for(int p:prePrimes) {
    		long low = (l/p)*p;
    		if(low < l) {
    			low += p;
    		}
    		if(low == p) {
    			low += p;
    		}
    		for(long j = low; j<= r; j += p) {
    			segSieve[(int) (j-l)] = false;
    		}
    	}
    	if(l==1) {
    		segSieve[0] = false;
    	}
    	return segSieve;
    }
//Euler Totent function
    static long countCoprimes(long n){
        ArrayList<Long> prime_factors=new ArrayList<>();
        long x=n,flag=0;
        while(x%2==0){
            if(flag==0) prime_factors.add(2L);
            flag=1;
            x/=2;
        }
        for(long i=3;i*i<=x;i+=2){
            flag=0;
            while(x%i==0){
                if(flag==0) prime_factors.add(i);
                flag=1;
                x/=i;
            }
        }
        if(x>2) prime_factors.add(x);
        double ans=(double)n;
        for(Long p:prime_factors){
            ans*=(1.0-(Double)1.0/p);
        }
        return (long)ans;
    }
	static long modulo = (long)1e9+7;
	public static long modinv(long x){
	    return modpow(x, modulo-2);
	}
	public static long modpow(long a, long b){
	    if(b==0){
	        return 1;
	    }
	    long x = modpow(a, b/2);
	    x = (x*x)%modulo;
	    if(b%2==1){
	        return (x*a)%modulo;
	    }
	    return x;
	}
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
		//it reads the data about the specified point and divide the data about it ,it is quite fast
		//than using direct

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
}


import java.io.*;
import java.util.*;
import java.util.concurrent.ArrayBlockingQueue;
import java.lang.*;
import java.math.*;
import java.text.DecimalFormat;
import java.lang.reflect.Array;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
public class Codeforces{
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static long MOD = (long)(1e9+7);
	//static long MOD = 998244353;
	static FastReader sc = new FastReader();
	static int pInf = Integer.MAX_VALUE;
	static int nInf = Integer.MIN_VALUE;
	public static void main(String[] args){
		int test = 1;
		test = sc.nextInt();
		while(test-->0){
			int n = sc.nextInt();
			long k = sc.nextLong();
			long[] a = new long[n];
			long max = Long.MIN_VALUE;
			for(int i = 0; i < n; i++) {
				a[i] = sc.nextLong();
				max = Math.max(max, a[i]);
			}
			long[] odd = new long[n];
			long[] even = new long[n];
			long temp = Long.MIN_VALUE;
			for(int i = 0; i < n; i++) {
				odd[i] = max-a[i];
				temp = Math.max(temp, odd[i]);
			}
			for(int i = 0; i < n; i++) {
				even[i] = temp-odd[i];
			}
			if((k&1)==1) {
				for(int i = 0; i < n; i++) {
					out.print(odd[i]+" ");
				}
				out.println();
			}
			else {
				for(int i = 0; i < n ; i++) {
					out.print(even[i]+" ");
				}
				out.println();
			}
		}
		out.close();
	}
	public static long mul(long a, long b){
	    return ((a%MOD)*(b%MOD))%MOD;
	}
	public static long add(long a, long b){
	    return ((a%MOD)+(b%MOD))%MOD;
	}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Integer.lowestOneBit(i)   Equals k where k is the position of the first one in the binary
//Integer.highestOneBit(i)  Equals k where k is the position of the last one in the binary
//Integer.bitCount(i)       returns the number of one-bits
//Collections.sort(A,(p1,p2)->(int)(p2.x-p1.x)) To sort ArrayList in descending order wrt values of x.
//            Arrays.parallelSort(a,new Comparator<TPair>() {
//      		public int compare(TPair a,TPair b) {
//        			if(a.y==b.y) return a.x-b.x;
//        			return b.y-a.y;
//        		}
//        	});
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//PrimeFactors
    public static ArrayList<Long> primeFactors(long n) {
        ArrayList<Long> arr = new ArrayList<>();
        if (n % 2 == 0)
            arr.add((long) 2);
        while (n % 2 == 0)
            n /= 2;
        for (long i = 3; i <= Math.sqrt(n); i += 2) {
            int flag = 0;
            while (n % i == 0) {
                n /= i;
                flag = 1;
            }
            if (flag == 1)
                arr.add(i);
        }
        if (n > 2)
            arr.add(n);
        return arr;
    }
//Pair Class
	static class Pair implements Comparable<Pair>{
		int x;
		int y;
		public Pair(int x, int y) {
			this.x = x;
			this.y = y;
		}
		@Override
		public int compareTo(Pair o) {
			if(this.x==o.x){
			    return (this.y-o.y);
			}
			return (this.x-o.x);
		}
	}
	static class TPair{
		int min;
		int max;
		int c;
		public TPair(int min, int max, int c) {
			this.min = min;
			this.max = max;
			this.c = c;
		}
	}
//nCr
	static long ncr(long n, long k) {
        long ret = 1;
        for (long x = n; x > n - k; x--) {
            ret *= x;
            ret /= (n - x + 1);
        }

        return ret;
    }
	static long finextDoubleMMI_fermat(long n,int M)
    {
        return fastExpo(n,M-2);
    }

    static long nCrModPFermat(int n, int r, int p)
    {
        if (r == 0)
            return 1;
        long[] fac = new long[n+1];
        fac[0] = 1;
        for (int i = 1 ;i <= n; i++)
            fac[i] = fac[i-1] * i % p;
        return (fac[n]* finextDoubleMMI_fermat(fac[r], p)% p * finextDoubleMMI_fermat(fac[n-r], p) % p) % p;
    }
//Merge Sort
	static void merge(long arr[], int l, int m, int r)
    {
        // Find sizes of two subarrays to be merged
        int n1 = m - l + 1;
        int n2 = r - m;

        /* Create temp arrays */
        long L[] = new long [n1];
        long R[] = new long [n2];

        /*Copy data to temp arrays*/
        for (int i=0; i<n1; ++i)
            L[i] = arr[l + i];
        for (int j=0; j<n2; ++j)
            R[j] = arr[m + 1+ j];

        /* Merge the temp arrays */

        // Initial indexes of first and second subarrays
        int i = 0, j = 0;

        // Initial index of merged subarry array
        int k = l;
        while (i < n1 && j < n2)
        {
            if (L[i] <= R[j])
            {
                arr[k] = L[i];
                i++;
            }
            else
            {
                arr[k] = R[j];
                j++;
            }
            k++;
        }

        /* Copy remaining elements of L[] if any */
        while (i < n1)
        {
            arr[k] = L[i];
            i++;
            k++;
        }

        /* Copy remaining elements of R[] if any */
        while (j < n2)
        {
            arr[k] = R[j];
            j++;
            k++;
        }
    }

    // Main function that sorts arr[l..r] using
    // merge()
    static void sort(long arr[], int l, int r)
    {
        if (l < r)
        {
            // Find the middle point
            int m = (l+r)/2;

            // Sort first and second halves
            sort(arr, l, m);
            sort(arr , m+1, r);

            // Merge the sorted halves
            merge(arr, l, m, r);
        }
    }
//Brian Kernighan’s Algorithm
    static long countSetBits(long n){
        if(n==0) return 0;
        return 1+countSetBits(n&(n-1));
    }
//Factorial
    static long factorial(long n){
        if(n==1) return 1;
        if(n==2) return 2;
        if(n==3) return 6;
        return n*factorial(n-1);
    }
//Euclidean Algorithm
    static long gcd(long A,long B){
        if(B==0) return A;
        return gcd(B,A%B);
    }
//Modular Exponentiation
    static long fastExpo(long x,long n){
        if(n==0) return 1;
        if((n&1)==0) return fastExpo((x*x)%MOD,n/2)%MOD;
        return ((x%MOD)*fastExpo((x*x)%MOD,(n-1)/2))%MOD;
    }
//AKS Algorithm
    static boolean isPrime(long n){
        if(n<=1) return false;
        if(n<=3) return true;
        if(n%2==0 || n%3==0) return false;
        for(int i=5;i<=Math.sqrt(n);i+=6)
            if(n%i==0 || n%(i+2)==0) return false;
        return true;
    }
//Reverse an array
    static <T> void reverse(T arr[],int l,int r){
    	Collections.reverse(Arrays.asList(arr).subList(l, r));
    }
//Sieve of eratosthenes
    static int[] findPrimes(int n){
        boolean isPrime[]=new boolean[n+1];
        ArrayList<Integer> a=new ArrayList<>();
        int result[];
        Arrays.fill(isPrime,true);
        isPrime[0]=false;
        isPrime[1]=false;
        for(int i=2;i*i<=n;++i){
            if(isPrime[i]==true){
                for(int j=i*i;j<=n;j+=i) isPrime[j]=false;
            }
        }
        for(int i=0;i<=n;i++) if(isPrime[i]==true) a.add(i);
        result=new int[a.size()];
        for(int i=0;i<a.size();i++) result[i]=a.get(i);
        return result;

    }
//Indivisual factors of all nos till n
    static ArrayList<Integer>[] indiFactors(int n){
    	ArrayList<Integer>[] A = new ArrayList[n+1];
    	for(int i = 0; i <= n; i++) {
    		A[i] = new ArrayList<>();
    	}
    	int[] sieve = new int[n+1];
    	for(int i=2;i<=n;i++) {
       		if(sieve[i]==0) {
       			for(int j=i;j<=n;j+=i) if(sieve[j]==0) {
       				//sieve[j]=i;
       				A[i].add(j);
       			}
       		}
       	}
    	return A;
    }
//Segmented Sieve
    static boolean[] segmentedSieve(long l, long r){
    	boolean[] segSieve = new boolean[(int)(r-l+1)];
    	Arrays.fill(segSieve, true);
    	int[] prePrimes = findPrimes((int)Math.sqrt(r));
    	for(int p:prePrimes) {
    		long low = (l/p)*p;
    		if(low < l) {
    			low += p;
    		}
    		if(low == p) {
    			low += p;
    		}
    		for(long j = low; j<= r; j += p) {
    			segSieve[(int) (j-l)] = false;
    		}
    	}
    	if(l==1) {
    		segSieve[0] = false;
    	}
    	return segSieve;
    }
//Euler Totent function
    static long countCoprimes(long n){
        ArrayList<Long> prime_factors=new ArrayList<>();
        long x=n,flag=0;
        while(x%2==0){
            if(flag==0) prime_factors.add(2L);
            flag=1;
            x/=2;
        }
        for(long i=3;i*i<=x;i+=2){
            flag=0;
            while(x%i==0){
                if(flag==0) prime_factors.add(i);
                flag=1;
                x/=i;
            }
        }
        if(x>2) prime_factors.add(x);
        double ans=(double)n;
        for(Long p:prime_factors){
            ans*=(1.0-(Double)1.0/p);
        }
        return (long)ans;
    }
	static long modulo = (long)1e9+7;
	public static long modinv(long x){
	    return modpow(x, modulo-2);
	}
	public static long modpow(long a, long b){
	    if(b==0){
	        return 1;
	    }
	    long x = modpow(a, b/2);
	    x = (x*x)%modulo;
	    if(b%2==1){
	        return (x*a)%modulo;
	    }
	    return x;
	}
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
		//it reads the data about the specified point and divide the data about it ,it is quite fast
		//than using direct

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
}


import java.io.*;
import java.util.*;
import java.util.concurrent.ArrayBlockingQueue;
import java.lang.*;
import java.math.*;
import java.text.DecimalFormat;
import java.lang.reflect.Array;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
public class Codeforces{
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static long MOD = (long)(1e9+7);
	//static long MOD = 998244353;
	static FastReader sc = new FastReader();
	static int pInf = Integer.MAX_VALUE;
	static int nInf = Integer.MIN_VALUE;
	public static void main(String[] args){
		int test = 1;
		test = sc.nextInt();
		while(test-->0){
			int n = sc.nextInt();
			int k = sc.nextInt();
			long[] a = new long[n];
			long max = Long.MIN_VALUE;
			for(int i = 0; i < n; i++) {
				a[i] = sc.nextLong();
				max = Math.max(max, a[i]);
			}
			long[] odd = new long[n];
			long[] even = new long[n];
			long temp = Long.MIN_VALUE;
			for(int i = 0; i < n; i++) {
				odd[i] = max-a[i];
				temp = Math.max(temp, odd[i]);
			}
			for(int i = 0; i < n; i++) {
				even[i] = temp-odd[i];
			}
			if((k&1)==1) {
				for(int i = 0; i < n; i++) {
					out.print(odd[i]+" ");
				}
				out.println();
			}
			else {
				for(int i = 0; i < n ; i++) {
					out.print(even[i]+" ");
				}
				out.println();
			}
		}
		out.close();
	}
	public static long mul(long a, long b){
	    return ((a%MOD)*(b%MOD))%MOD;
	}
	public static long add(long a, long b){
	    return ((a%MOD)+(b%MOD))%MOD;
	}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Integer.lowestOneBit(i)   Equals k where k is the position of the first one in the binary
//Integer.highestOneBit(i)  Equals k where k is the position of the last one in the binary
//Integer.bitCount(i)       returns the number of one-bits
//Collections.sort(A,(p1,p2)->(int)(p2.x-p1.x)) To sort ArrayList in descending order wrt values of x.
//            Arrays.parallelSort(a,new Comparator<TPair>() {
//      		public int compare(TPair a,TPair b) {
//        			if(a.y==b.y) return a.x-b.x;
//        			return b.y-a.y;
//        		}
//        	});
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//PrimeFactors
    public static ArrayList<Long> primeFactors(long n) {
        ArrayList<Long> arr = new ArrayList<>();
        if (n % 2 == 0)
            arr.add((long) 2);
        while (n % 2 == 0)
            n /= 2;
        for (long i = 3; i <= Math.sqrt(n); i += 2) {
            int flag = 0;
            while (n % i == 0) {
                n /= i;
                flag = 1;
            }
            if (flag == 1)
                arr.add(i);
        }
        if (n > 2)
            arr.add(n);
        return arr;
    }
//Pair Class
	static class Pair implements Comparable<Pair>{
		int x;
		int y;
		public Pair(int x, int y) {
			this.x = x;
			this.y = y;
		}
		@Override
		public int compareTo(Pair o) {
			if(this.x==o.x){
			    return (this.y-o.y);
			}
			return (this.x-o.x);
		}
	}
	static class TPair{
		int min;
		int max;
		int c;
		public TPair(int min, int max, int c) {
			this.min = min;
			this.max = max;
			this.c = c;
		}
	}
//nCr
	static long ncr(long n, long k) {
        long ret = 1;
        for (long x = n; x > n - k; x--) {
            ret *= x;
            ret /= (n - x + 1);
        }

        return ret;
    }
	static long finextDoubleMMI_fermat(long n,int M)
    {
        return fastExpo(n,M-2);
    }

    static long nCrModPFermat(int n, int r, int p)
    {
        if (r == 0)
            return 1;
        long[] fac = new long[n+1];
        fac[0] = 1;
        for (int i = 1 ;i <= n; i++)
            fac[i] = fac[i-1] * i % p;
        return (fac[n]* finextDoubleMMI_fermat(fac[r], p)% p * finextDoubleMMI_fermat(fac[n-r], p) % p) % p;
    }
//Merge Sort
	static void merge(long arr[], int l, int m, int r)
    {
        // Find sizes of two subarrays to be merged
        int n1 = m - l + 1;
        int n2 = r - m;

        /* Create temp arrays */
        long L[] = new long [n1];
        long R[] = new long [n2];

        /*Copy data to temp arrays*/
        for (int i=0; i<n1; ++i)
            L[i] = arr[l + i];
        for (int j=0; j<n2; ++j)
            R[j] = arr[m + 1+ j];

        /* Merge the temp arrays */

        // Initial indexes of first and second subarrays
        int i = 0, j = 0;

        // Initial index of merged subarry array
        int k = l;
        while (i < n1 && j < n2)
        {
            if (L[i] <= R[j])
            {
                arr[k] = L[i];
                i++;
            }
            else
            {
                arr[k] = R[j];
                j++;
            }
            k++;
        }

        /* Copy remaining elements of L[] if any */
        while (i < n1)
        {
            arr[k] = L[i];
            i++;
            k++;
        }

        /* Copy remaining elements of R[] if any */
        while (j < n2)
        {
            arr[k] = R[j];
            j++;
            k++;
        }
    }

    // Main function that sorts arr[l..r] using
    // merge()
    static void sort(long arr[], int l, int r)
    {
        if (l < r)
        {
            // Find the middle point
            int m = (l+r)/2;

            // Sort first and second halves
            sort(arr, l, m);
            sort(arr , m+1, r);

            // Merge the sorted halves
            merge(arr, l, m, r);
        }
    }
//Brian Kernighan’s Algorithm
    static long countSetBits(long n){
        if(n==0) return 0;
        return 1+countSetBits(n&(n-1));
    }
//Factorial
    static long factorial(long n){
        if(n==1) return 1;
        if(n==2) return 2;
        if(n==3) return 6;
        return n*factorial(n-1);
    }
//Euclidean Algorithm
    static long gcd(long A,long B){
        if(B==0) return A;
        return gcd(B,A%B);
    }
//Modular Exponentiation
    static long fastExpo(long x,long n){
        if(n==0) return 1;
        if((n&1)==0) return fastExpo((x*x)%MOD,n/2)%MOD;
        return ((x%MOD)*fastExpo((x*x)%MOD,(n-1)/2))%MOD;
    }
//AKS Algorithm
    static boolean isPrime(long n){
        if(n<=1) return false;
        if(n<=3) return true;
        if(n%2==0 || n%3==0) return false;
        for(int i=5;i<=Math.sqrt(n);i+=6)
            if(n%i==0 || n%(i+2)==0) return false;
        return true;
    }
//Reverse an array
    static <T> void reverse(T arr[],int l,int r){
    	Collections.reverse(Arrays.asList(arr).subList(l, r));
    }
//Sieve of eratosthenes
    static int[] findPrimes(int n){
        boolean isPrime[]=new boolean[n+1];
        ArrayList<Integer> a=new ArrayList<>();
        int result[];
        Arrays.fill(isPrime,true);
        isPrime[0]=false;
        isPrime[1]=false;
        for(int i=2;i*i<=n;++i){
            if(isPrime[i]==true){
                for(int j=i*i;j<=n;j+=i) isPrime[j]=false;
            }
        }
        for(int i=0;i<=n;i++) if(isPrime[i]==true) a.add(i);
        result=new int[a.size()];
        for(int i=0;i<a.size();i++) result[i]=a.get(i);
        return result;

    }
//Indivisual factors of all nos till n
    static ArrayList<Integer>[] indiFactors(int n){
    	ArrayList<Integer>[] A = new ArrayList[n+1];
    	for(int i = 0; i <= n; i++) {
    		A[i] = new ArrayList<>();
    	}
    	int[] sieve = new int[n+1];
    	for(int i=2;i<=n;i++) {
       		if(sieve[i]==0) {
       			for(int j=i;j<=n;j+=i) if(sieve[j]==0) {
       				//sieve[j]=i;
       				A[i].add(j);
       			}
       		}
       	}
    	return A;
    }
//Segmented Sieve
    static boolean[] segmentedSieve(long l, long r){
    	boolean[] segSieve = new boolean[(int)(r-l+1)];
    	Arrays.fill(segSieve, true);
    	int[] prePrimes = findPrimes((int)Math.sqrt(r));
    	for(int p:prePrimes) {
    		long low = (l/p)*p;
    		if(low < l) {
    			low += p;
    		}
    		if(low == p) {
    			low += p;
    		}
    		for(long j = low; j<= r; j += p) {
    			segSieve[(int) (j-l)] = false;
    		}
    	}
    	if(l==1) {
    		segSieve[0] = false;
    	}
    	return segSieve;
    }
//Euler Totent function
    static long countCoprimes(long n){
        ArrayList<Long> prime_factors=new ArrayList<>();
        long x=n,flag=0;
        while(x%2==0){
            if(flag==0) prime_factors.add(2L);
            flag=1;
            x/=2;
        }
        for(long i=3;i*i<=x;i+=2){
            flag=0;
            while(x%i==0){
                if(flag==0) prime_factors.add(i);
                flag=1;
                x/=i;
            }
        }
        if(x>2) prime_factors.add(x);
        double ans=(double)n;
        for(Long p:prime_factors){
            ans*=(1.0-(Double)1.0/p);
        }
        return (long)ans;
    }
	static long modulo = (long)1e9+7;
	public static long modinv(long x){
	    return modpow(x, modulo-2);
	}
	public static long modpow(long a, long b){
	    if(b==0){
	        return 1;
	    }
	    long x = modpow(a, b/2);
	    x = (x*x)%modulo;
	    if(b%2==1){
	        return (x*a)%modulo;
	    }
	    return x;
	}
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
		//it reads the data about the specified point and divide the data about it ,it is quite fast
		//than using direct

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
}


import java.util.*;
public class cpomkarandcook {
    public static void main (String[] args) {
        //code
        Scanner in = new Scanner(System.in);
        int T = in.nextInt();
        for (int t = 0; t < T; t++) {
            int n = in.nextInt();
            int k = in.nextInt();
            int a[] = new int[n];
            int d = Integer.MIN_VALUE;
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
                if (d < a[i]) {
                    d = a[i];
                }
            }
            for (int i = 0; i < n; i++) {
                System.out.print((d-a[i])+" ");
            }
            System.out.println();
        }
    }
}


import java.util.*;
public class cpomkarandcook {
    public static void main (String[] args) {
        //code
        Scanner in = new Scanner(System.in);
        int T = in.nextInt();
        for (int t = 0; t < T; t++) {
            int n = in.nextInt();
            int k = in.nextInt();
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            if(k%2==0){
                k=2;
            }
            else{
                k=1;
            }
            for(int i=0;i<k;i++){
                int d=a[0];
                for(int j=0;j<n;j++){
                    if(d<a[j]){
                        d=a[j];
                    }
                }
                for(int j=0;j<n;j++){
                    a[j]=d-a[j];
                }
            }
            for(int j=0;j<n;j++){
                System.out.print(a[j]+" ");
            }
            System.out.println();
        }
    }
}


import java.util.*;
public class cpomkarandcook {
    public static void main (String[] args) {
        //code
        Scanner in = new Scanner(System.in);
        int T = in.nextInt();
        for (int t = 0; t < T; t++) {
            int n = in.nextInt();
            int k = in.nextInt();
            long a[] = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            if(k%2==0){
                k=2;
            }
            else{
                k=1;
            }
            for(int i=0;i<k;i++){
                long d=a[0];
                for(int j=0;j<n;j++){
                    if(d<a[j]){
                        d=a[j];
                    }
                }
                for(int j=0;j<n;j++){
                    a[j]=d-a[j];
                }
            }
            for(int j=0;j<n;j++){
                System.out.print(a[j]+" ");
            }
            System.out.println();
        }
    }
}


import java.util.*;
public class cpomkarandcook {
    public static void main (String[] args) {
        //code
        Scanner in = new Scanner(System.in);
        int T = in.nextInt();
        for (int t = 0; t < T; t++) {
            int n = in.nextInt();
            long k = in.nextLong();
            long[] a;
            a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            if(k%2==0){
                k=2;
            }
            else{
                k=1;
            }
            for(int i=0;i<k;i++){
                long d=a[0];
                for(int j=0;j<n;j++){
                    if(d<a[j]){
                        d=a[j];
                    }
                }
                for(int j=0;j<n;j++){
                    a[j]=d-a[j];
                }
            }
            for(int j=0;j<n;j++){
                System.out.print(a[j]+" ");
            }
            System.out.println();
        }
    }
}


import java.io.*;
import java.util.*;

public class B {
	public static void main(String[] args) {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int T = fs.nextInt();
		for (int tt = 0; tt < T; tt++) {
			int n = fs.nextInt();
			int k = fs.nextInt();
			int[] a = fs.readArray(n);
			int max = a[0];
			int min = a[0];
			for (int i = 1; i < n; i++) {
				if (a[i] > a[0]) max = a[i];
				if (a[i] < a[0]) min = a[i];
			}
			for (int i = 0; i < n; i++) {
				a[i] = max - a[i];
			}
			if (k % 2 == 0)
				for (int i = 0; i < n; i++) {
					a[i] = max - min - a[i];
				}
			if (max == min) for (int i = 0; i < n; i++) out.print(0 + " ");
			else for (int i = 0; i < n; i++) out.print(a[i] + " ");
			out.println();
		}
		out.close();
	}
	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}


import java.io.*;
import java.util.*;

public class B {
	public static void main(String[] args) {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int T = fs.nextInt();
		for (int tt = 0; tt < T; tt++) {
			int n = fs.nextInt();
			long k = fs.nextLong();
			int[] a = fs.readArray(n);
			int max = a[0];
			int min = a[0];
			for (int i = 1; i < n; i++) {
				if (a[i] > max) max = a[i];
				if (a[i] < min) min = a[i];
			}
			if (k % 2 == 1) for (int i = 0; i < n; i++) a[i] = max - a[i];
			else for (int i = 0; i < n; i++) a[i] = a[i] - min;
			for (int i = 0; i < n; i++) out.print(a[i] + " ");
			out.println();
		}
		out.close();
	}
	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}


import java.io.*;
import java.util.*;

public class B {
	public static void main(String[] args) {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int T = fs.nextInt();
		for (int tt = 0; tt < T; tt++) {
			int n = fs.nextInt();
			long k = fs.nextLong();
			int[] a = fs.readArray(n);
			int max = a[0];
			int min = a[0];
			for (int i = 1; i < n; i++) {
				if (a[i] > a[0]) max = a[i];
				if (a[i] < a[0]) min = a[i];
			}
			for (int i = 0; i < n; i++) {
				a[i] = max - a[i];
			}
			if (k % 2 == 0)
				for (int i = 0; i < n; i++) {
					a[i] = max - min - a[i];
				}
			for (int i = 0; i < n; i++) out.print(a[i] + " ");
			out.println();
		}
		out.close();
	}
	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}


import java.io.*;
import java.util.*;

public class B {
	public static void main(String[] args) {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int T = fs.nextInt();
		for (int tt = 0; tt < T; tt++) {
			int n = fs.nextInt();
			int k = fs.nextInt();
			int[] a = fs.readArray(n);
			int max = a[0];
			int min = a[0];
			for (int i = 1; i < n; i++) {
				if (a[i] > a[0]) max = a[i];
				if (a[i] < a[0]) min = a[i];
			}
			for (int i = 0; i < n; i++) {
				a[i] = max - a[i];
			}
			if (k % 2 == 0)
				for (int i = 0; i < n; i++) {
					a[i] = min - a[i];
				}
			if (max == min) for (int i = 0; i < n; i++) out.print(0 + " ");
			else for (int i = 0; i < n; i++) out.print(a[i] + " ");
			out.println();
		}
		out.close();
	}
	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}


import java.util.*;
public class codeforces
{
    public static void main(String args[])
    {
        Scanner ob = new Scanner(System.in);
        int t = ob.nextInt();
        while(t-- > 0)
        {
            int n = ob.nextInt();
            int clock = ob.nextInt();
            long[] arr = new long[n];
            for(int i=0;i<n;i++)
            {
                int num = ob.nextInt();
                arr[i] = (long)num;
            }
            //////
            for(int i=1;i<=clock;i++)//first round
            {
                long m = findMax(arr);
                for(int j=0;j<arr.length;j++)
                {
                    arr[j] = m - arr[j];
                }
            }
            /////print the answer
            for(int i=0;i<n;i++)
            {
                System.out.print(arr[i] + " ");
            }
            System.out.println();
        }
    }
    public static long findMax(long[] arr)
    {
        long m = -2434546575757;
        for(int i=0;i<arr.length;i++)
        {
            if(m < arr[i])
            {
                m = arr[i];
            }
        }
        return m;
    }
}


import java.util.*;
public class codeforces
{
    public static void main(String args[])
    {
        Scanner ob = new Scanner(System.in);
        int t = ob.nextInt();
        while(t-- > 0)
        {
            int n = ob.nextInt();
            int clock = ob.nextInt();
            int[] arr = new int[n];
            for(int i=0;i<n;i++)
            {
                int num = ob.nextInt();
                arr[i] = num;
            }
            //////
            for(int i=1;i<=clock;i++)//first round
            {
                int m = findMax(arr);
                for(int j=0;j<arr.length;j++)
                {
                    arr[j] = m - arr[j];
                }
            }
            /////print the answer
            for(int i=0;i<n;i++)
            {
                System.out.print(arr[i] + " ");
            }
            System.out.println();
        }
    }
    public static int findMax(int[] arr)
    {
        int m = Integer.MIN_VALUE;
        for(int i=0;i<arr.length;i++)
        {
            if(m < arr[i])
            {
                m = arr[i];
            }
        }
        return m;
    }
}


import java.util.*;
public class codeforces
{
    public static void main(String args[])
    {
        Scanner ob = new Scanner(System.in);
        int t = ob.nextInt();
        while(t-- > 0)
        {
            int n = ob.nextInt();
            int clock = ob.nextInt();
            long[] arr = new long[n];
            for(int i=0;i<n;i++)
            {
                int num = ob.nextInt();
                arr[i] = (long)num;
            }
            //////
            for(int i=1;i<=clock;i++)//first round
            {
                long m = findMax(arr);
                for(int j=0;j<arr.length;j++)
                {
                    arr[j] = m - arr[j];
                }
            }
            /////print the answer
            for(int i=0;i<n;i++)
            {
                System.out.print(arr[i] + " ");
            }
            System.out.println();
        }
    }
    public static long findMax(long[] arr)
    {
        long m = -1000000000;
        for(int i=0;i<arr.length;i++)
        {
            if(m < arr[i])
            {
                m = arr[i];
            }
        }
        return m;
    }
}


import java.util.*;
public class codeforces
{
    public static void main(String args[])
    {
        Scanner ob = new Scanner(System.in);
        int t = ob.nextInt();
        while(t-- > 0)
        {
            int n = ob.nextInt();
            int clock = ob.nextInt();
            int[] arr = new int[n];
            for(int i=0;i<n;i++)
            {
                int num = ob.nextInt();
                arr[i] = num;
            }
            //////
            for(int i=1;i<=count;i++)//first round
            {
                int m = findMax(arr);
                for(int i=0;i<arr.length;i++)
                {
                    arr[i] = m - arr[i];
                }
            }
            /////print the answer
            for(int i=0;i<n;i++)
            {
                System.out.print(arr[i] + " ");
            }
            System.out.println();
        }
    }
    public int findMax(int[][] arr)
    {
        int m = Integer.MIN_VALUE;
        for(int i=0;i<arr.length;i++)
        {
            if(m < arr[i])
            {
                m = arr[i];
            }
        }
        return m;
    }
}


import java.util.*;
public class codeforces
{
    public static void main(String args[])
    {
        Scanner ob = new Scanner(System.in);
        int t = ob.nextInt();
        while(t-- > 0)
        {
            int n = ob.nextInt();
            long clock = ob.nextLong();
            int[] arr = new int[n];
            for(int i=0;i<n;i++)
            {
                int num = ob.nextInt();
                arr[i] = num;
            }
            //////
            for(long i=1;i<=clock;i++)//first round
            {
                int m = findMax(arr);
                for(int j=0;j<arr.length;j++)
                {
                    arr[j] = m - arr[j];
                }
            }
            /////print the answer
            for(int i=0;i<n;i++)
            {
                System.out.print(arr[i] + " ");
            }
            System.out.println();
        }
    }
    public static int findMax(int[] arr)
    {
        int m = -1000000000;
        for(int i=0;i<arr.length;i++)
        {
            if(m < arr[i])
            {
                m = arr[i];
            }
        }
        return m;
    }
}


import java.util.*;
public class codeforces
{
    public static void main(String args[])
    {
        Scanner ob = new Scanner(System.in);
        int t = ob.nextInt();
        while(t-- > 0)
        {
            int n = ob.nextInt();
            long clock = ob.nextLong();
            int[] arr = new int[n];
            for(int i=0;i<n;i++)
            {
                int num = ob.nextInt();
                arr[i] = num;
            }
            //////
            while(clock > 0)//first round
            {
                int m = findMax(arr);
                for(int j=0;j<arr.length;j++)
                {
                    arr[j] = m - arr[j];
                }
                clock = clock - 1;
                if(allPosi(arr))
                {
                    break;
                }
            }
            if(clock%2 == 1)//e.g - 1 , 3 , 5
            {
                int m = findMax(arr);
                for(int j=0;j<arr.length;j++)
                {
                    arr[j] = m - arr[j];
                }
            }
            ////////
            /////print the answer
            for(int i=0;i<n;i++)
            {
                System.out.print(arr[i] + " ");
            }
            System.out.println();
        }
    }
    public static boolean allPosi(int[] arr)
    {
        for(int i=0;i<arr.length;i++)
        {
            if(arr[i] < 0)
            {
                return false;
            }
        }
        return true;
    }
    public static int findMax(int[] arr)
    {
        int m = -1000000000;
        for(int i=0;i<arr.length;i++)
        {
            if(m < arr[i])
            {
                m = arr[i];
            }
        }
        return m;
    }
}


import java.util.*;
public class codeforces
{
    public static void main(String args[])
    {
        Scanner ob = new Scanner(System.in);
        int t = ob.nextInt();
        while(t-- > 0)
        {
            int n = ob.nextInt();
            long clock = ob.nextLong();
            int[] arr = new int[n];
            for(int i=0;i<n;i++)
            {
                int num = ob.nextInt();
                arr[i] = num;
            }
            //////
            while(clock > 0)//first round
            {
                int m = findMax(arr);
                for(int j=0;j<arr.length;j++)
                {
                    arr[j] = m - arr[j];
                }
                clock = clock - 1;
                if(allPosi(arr))
                {
                    break;
                }
            }
            if(clock%2 == 1)//e.g - 1 , 3 , 5
            {
                int m = findMax(arr);
                for(int j=0;j<arr.length;j++)
                {
                    arr[j] = m - arr[j];
                }
            }
            ////////
            /////print the answer
            for(int i=0;i<n;i++)
            {
                System.out.print(arr[i] + " ");
            }
            System.out.println();
        }
    }
    public static int findMax(int[] arr)
    {
        int m = -1000000000;
        for(int i=0;i<arr.length;i++)
        {
            if(m < arr[i])
            {
                m = arr[i];
            }
        }
        return m;
    }
}


import java.util.*;
public class codeforces
{
    public static void main(String args[])
    {
        Scanner ob = new Scanner(System.in);
        int t = ob.nextInt();
        while(t-- > 0)
        {
            int n = ob.nextInt();
            int clock = ob.nextInt();
            long[] arr = new long[n];
            for(int i=0;i<n;i++)
            {
                int num = ob.nextInt();
                arr[i] = (long)num;
            }
            //////
            for(int i=1;i<=clock;i++)//first round
            {
                long m = findMax(arr);
                for(int j=0;j<arr.length;j++)
                {
                    arr[j] = m - arr[j];
                }
            }
            /////print the answer
            for(int i=0;i<n;i++)
            {
                System.out.print(arr[i] + " ");
            }
            System.out.println();
        }
    }
    public static long findMax(long[] arr)
    {
        long m = -100000000000000;
        for(int i=0;i<arr.length;i++)
        {
            if(m < arr[i])
            {
                m = arr[i];
            }
        }
        return m;
    }
}


import java.util.*;
public class codeforces
{
    public static void main(String args[])
    {
        Scanner ob = new Scanner(System.in);
        int t = ob.nextInt();
        while(t-- > 0)
        {
            int n = ob.nextInt();
            int clock = ob.nextInt();
            int[] arr = new int[n];
            for(int i=0;i<n;i++)
            {
                int num = ob.nextInt();
                arr[i] = num;
            }
            //////
            for(int i=1;i<=clock;i++)//first round
            {
                int m = findMax(arr);
                for(int j=0;j<arr.length;j++)
                {
                    arr[j] = m - arr[j];
                }
            }
            /////print the answer
            for(int i=0;i<n;i++)
            {
                System.out.print(arr[i] + " ");
            }
            System.out.println();
        }
    }
    public static int findMax(int[] arr)
    {
        int m = -1000000000;
        for(int i=0;i<arr.length;i++)
        {
            if(m < arr[i])
            {
                m = arr[i];
            }
        }
        return m;
    }
}


import java.util.*;
public class codeforces
{
    public static void main(String args[])
    {
        Scanner ob = new Scanner(System.in);
        int t = ob.nextInt();
        while(t-- > 0)
        {
            int n = ob.nextInt();
            int clock = ob.nextInt();
            int[] arr = new int[n];
            for(int i=0;i<n;i++)
            {
                int num = ob.nextInt();
                arr[i] = num;
            }
            //////
            for(int i=1;i<=clock;i++)//first round
            {
                int m = findMax(arr);
                for(int j=0;j<arr.length;j++)
                {
                    arr[j] = m - arr[j];
                }
            }
            /////print the answer
            for(int i=0;i<n;i++)
            {
                System.out.print(arr[i] + " ");
            }
            System.out.println();
        }
    }
    public int findMax(int[] arr)
    {
        int m = Integer.MIN_VALUE;
        for(int i=0;i<arr.length;i++)
        {
            if(m < arr[i])
            {
                m = arr[i];
            }
        }
        return m;
    }
}


import java.util.*;
import java.io.*;
import java.math.BigInteger;

public class Main {
	public static int max (int a[] , int n) {
		int max = a[0];
		for(int i = 0; i<n; i++) {
			max = Math.max(max, a[i]);
		}
		return max;
	}
	public static void solve(InputReader in) {
		int n = in.readInt(), k = in.readInt();
		int a[] = new int[n];

		for(int i = 0; i<n; i++)
			a[i] = in.readInt();

		int max = max(a , n);

		for(int i = 0; i<n; i++)
			a[i] = max - a[i];

		max = max(a , n);
			     k--;
			     if(k % 2 == 1) {
			    	     for(int i =0; i<n; i++) {
			    	    	 System.out.print(max - a[i] + " ");
			    	     }
			     }
			     else {
			    	   for(int i = 0; i<n; i++) {
			    		   System.out.print(a[i] + " " );
			    	   }
			     }
		System.out.println();
	}

	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
		int t = in.readInt();
		while (t-- > 0)
			solve(in);
	}
}

class InputReader{
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	 public InputReader(InputStream stream) {
		this.stream = stream;
	}

     public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

     public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

     public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

     public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

     public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

     public String next() {
		return readString();
	}

     public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


import java.util.*;
import java.io.*;
import java.math.BigInteger;

public class Main {
	public static long max (long a[] , int n) {
		long max = a[0];
		for(int i = 0; i<n; i++) {
			max = Math.max(max, a[i]);
		}
		return max;
	}
	public static void solve(InputReader in) {
		int n = in.readInt(), k = in.readInt();
		long a[] = new long[n];

		for(int i = 0; i<n; i++)
			a[i] = in.readInt();

		long max = max(a , n);

		for(int i = 0; i<n; i++)
			a[i] = max - a[i];

		max = max(a , n);
			     k--;
			     if(k % 2 == 1) {
			    	     for(int i =0; i<n; i++) {
			    	    	 System.out.print(max - a[i] + " ");
			    	     }
			     }
			     else {
			    	   for(int i = 0; i<n; i++) {
			    		   System.out.print(a[i] + " " );
			    	   }
			     }
		System.out.println();
	}

	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
		int t = in.readInt();
		while (t-- > 0)
			solve(in);
	}
}

class InputReader{
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	 public InputReader(InputStream stream) {
		this.stream = stream;
	}

     public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

     public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

     public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

     public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

     public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

     public String next() {
		return readString();
	}

     public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


import java.util.*;
import java.io.*;
import java.math.BigInteger;

public class Main {
	public static long max (long a[] , int n) {
		long max = a[0];
		for(int i = 0; i<n; i++) {
			max = Math.max(max, a[i]);
		}
		return max;
	}
	public static void solve(InputReader in) {
		int n = in.readInt(), k = in.readInt();
		long a[] = new long[n];

		for(int i = 0; i<n; i++)
			a[i] = in.readInt();

		long max = max(a , n);

		for(int i = 0; i<n; i++)
			a[i] = max - a[i];

		max = max(a , n);
			     k--;
			     if((k&1) == 1) {
			    	     for(int i =0; i<n; i++) {
			    	    	 System.out.print(max - a[i] + " ");
			    	     }
			     }
			     else {
			    	   for(int i = 0; i<n; i++) {
			    		   System.out.print(a[i] + " " );
			    	   }
			     }
		System.out.println();
	}

	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
		int t = in.readInt();
		while (t-- > 0)
			solve(in);
	}
}

class InputReader{
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	 public InputReader(InputStream stream) {
		this.stream = stream;
	}

     public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

     public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

     public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

     public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

     public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

     public String next() {
		return readString();
	}

     public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


import java.util.*;
import java.io.*;
import java.math.BigInteger;

public class Main {
	public static void solve(InputReader in) {
		int n = in.readInt();
		int k = in.readInt();
		ArrayList<Integer> a = new ArrayList<>();
		for(int i = 0; i<n; i++) {
			a.add(in.readInt());
		}
		if(n == 1) {
			System.out.println(0);
			return;
		}
		int max = Collections.max(a);
		if(k % 2 == 1) {
		for(int i = 0; i<n; i++) {
			System.out.print(max - a.get(i) + " ");
		}
		System.out.println();
		}
		else {
			for(int i = 0; i<n; i++) {
				System.out.print(a.get(i) + " ");
			}
			System.out.println();
		}
	}

	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
		int t = in.readInt();
		while (t-- > 0)
			solve(in);
	}
}

class InputReader{
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	 public InputReader(InputStream stream) {
		this.stream = stream;
	}

     public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

     public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

     public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

     public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

     public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

     public String next() {
		return readString();
	}

     public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


import java.util.*;
import java.io.*;
import java.math.BigInteger;

public class Main {
	public static long max (long a[] , int n) {
		long max = a[0];
		for(int i = 0; i<n; i++) {
			max = Math.max(max, a[i]);
		}
		return max;
	}
	public static void solve(InputReader in) {
		int n = in.readInt(), k = in.readInt();
		long a[] = new long[n];

		for(int i = 0; i<n; i++)
			a[i] = in.readInt();

		long max = max(a , n);

		for(int i = 0; i<n; i++)
			a[i] = max - a[i];

		max = max(a , n);

		if(k == 1) for(int i = 0; i<n; i++) System.out.print(a[i] + " ");
		else {
			     k--;
			     if(k % 2 == 1) {
			    	     for(int i =0; i<n; i++) {
			    	    	 System.out.print(max - a[i] + " ");
			    	     }
			     }
			     else {
			    	   for(int i = 0; i<n; i++) {
			    		   System.out.print(a[i] + " " );
			    	   }
			     }
		}
		System.out.println();
	}

	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
		int t = in.readInt();
		while (t-- > 0)
			solve(in);
	}
}

class InputReader{
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	 public InputReader(InputStream stream) {
		this.stream = stream;
	}

     public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

     public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

     public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

     public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

     public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

     public String next() {
		return readString();
	}

     public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


import java.util.*;
import java.io.*;
import java.math.BigInteger;

public class Main {
	public static long max (long a[] , int n) {
		long max = a[0];
		for(int i = 0; i<n; i++) {
			max = Math.max(max, a[i]);
		}
		return max;
	}
	public static void solve(InputReader in) {
		int n = in.readInt(), k = in.readInt();
		long a[] = new long[n];

		for(int i = 0; i<n; i++)
			a[i] = in.readInt();

		long max = max(a , n);

		for(int i = 0; i<n; i++)
			a[i] = max - a[i];

		max = max(a , n);

		if(k == 1) for(int i = 0; i<n; i++) System.out.print(a[i] + " ");
		else {
			     k--;
			     if((k&1) == 1) {
			    	     for(int i =0; i<n; i++) {
			    	    	 System.out.print(max - a[i] + " ");
			    	     }
			     }
			     else {
			    	   for(int i = 0; i<n; i++) {
			    		   System.out.print(a[i] + " " );
			    	   }
			     }
		}
		System.out.println();
	}

	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
		int t = in.readInt();
		while (t-- > 0)
			solve(in);
	}
}

class InputReader{
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	 public InputReader(InputStream stream) {
		this.stream = stream;
	}

     public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

     public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

     public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

     public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

     public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

     public String next() {
		return readString();
	}

     public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}