#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long mod1 = 998244353;
const long long inf = 9223372036854775807ll;
const long long nax = 200005;
long long n, k, a[nax];
void solve() {
  cin >> n >> k;
  long long mx = -inf, nxt = -inf;
  for (long long i = (0); i < (n); i++) {
    cin >> a[i];
    mx = max(mx, a[i]);
  }
  for (long long i = (0); i < (n); i++) {
    a[i] = mx - a[i];
    nxt = max(nxt, a[i]);
  }
  if (k % 2) {
    for (long long i = (0); i < (n); i++) cout << a[i] << " ";
    cout << '\n';
    return;
  }
  mx = nxt;
  for (long long i = (0); i < (n); i++) {
    a[i] = mx - a[i];
    cout << a[i] << " ";
  }
  cout << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) solve();
  return 0;
}
