#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long c, d, i, j, k, l, m, n, x, y, z, r, sum = 0, ans;
  cin >> n >> k;
  long long a[n];
  d = LONG_MIN;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    d = max(d, a[i]);
  }
  if (k % 2)
    k = 1;
  else
    k = 2;
  for (j = 1; j <= k; j++) {
    x = LONG_MIN;
    for (i = 0; i < n; i++) {
      a[i] = d - a[i];
      x = max(a[i], x);
    }
    d = x;
  }
  for (i = 0; i < n; ++i) cout << a[i] << " ";
}
int main() {
  ios::sync_with_stdio(0);
  ;
  int t;
  cin >> t;
  while (t--) {
    solve();
    cout << '\n';
  }
  return 0;
}
