#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int i, j, n, test, k, l;
  cin >> test;
  for (i = 0; i < test; i++) {
    cin >> n >> k;
    long long int arr[n];
    for (j = 0; j < n; j++) {
      cin >> arr[j];
    }
    l = *max_element(arr, arr + n);
    {
      for (j = 0; j < n; j++) arr[j] = l - arr[j];
    }
    l = *max_element(arr, arr + n);
    if (k % 2 == 0)
      for (j = 0; j < n; j++) arr[j] = l - arr[j];
    for (j = 0; j < n; j++) {
      cout << arr[j] << " ";
    }
    cout << endl;
  }
  return 0;
}
