#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, k, d = LLONG_MIN;
  cin >> n >> k;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > d) d = a[i];
  }
  if (k > 0) {
    long long nex = LLONG_MIN;
    for (long long i = 0; i < n; i++) {
      a[i] = d - a[i];
      if (a[i] > nex) nex = a[i];
    }
    if (!(k & 1)) {
      d = nex;
      for (long long i = 0; i < n; i++) {
        a[i] = d - a[i];
        if (a[i] > nex) nex = d;
      }
    }
  }
  for (long long i = 0; i < n; i++) cout << a[i] << " ";
  cout << "\n";
}
signed main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long T = 1;
  cin >> T;
  while (T--) solve();
  return 0;
}
