#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, i, j, n;
  signed long long int k;
  cin >> t;
  while (t > 0) {
    cin >> n >> k;
    int arr[n];
    int Maax = INT_MIN;
    for (i = 0; i < n; i++) {
      cin >> arr[i];
      Maax = max(Maax, arr[i]);
    }
    k--;
    int arr1[n];
    int arr2[n];
    int Maax1 = INT_MIN;
    for (i = 0; i < n; i++) {
      arr1[i] = Maax - arr[i];
      Maax1 = max(Maax1, arr1[i]);
    }
    for (i = 0; i < n; i++) {
      arr2[i] = Maax1 - arr1[i];
    }
    for (i = 0; i < n; i++) {
      if (k % 2 == 0)
        cout << arr1[i] << " ";
      else
        cout << arr2[i] << " ";
    }
    cout << endl;
    t--;
  }
}
