#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, i, j;
  cin >> t;
  for (j = 0; j < t; j++) {
    long long n, k, a, mx, mx2, p;
    vector<long long> ar, ar1, ar2;
    cin >> n >> k;
    for (i = 0; i < n; i++) {
      cin >> a;
      ar.push_back(a);
    }
    mx = *max_element(ar.begin(), ar.end());
    for (i = 0; i < n; i++) {
      p = mx - ar[i];
      ar1.push_back(p);
    }
    mx2 = *max_element(ar1.begin(), ar1.end());
    for (i = 0; i < n; i++) {
      p = mx2 - ar1[i];
      ar2.push_back(p);
    }
    if (k % 2 == 0) {
      for (i = 0; i < n; i++) cout << ar2[i] << " ";
    } else {
      for (i = 0; i < n; i++) cout << ar1[i] << " ";
    }
    cout << endl;
  }
  return 0;
}
