#include <bits/stdc++.h>
using namespace std;
const int64_t maxn = 2e5 + 5;
int64_t ar[maxn];
bool all(int64_t n) {
  for (int64_t i = 1; i < n; i++)
    if (ar[i] != ar[i - 1]) return 0;
  return 1;
}
void solve() {
  int64_t n, k;
  cin >> n >> k;
  int64_t mx = -1000000007, mn = 1000000007;
  for (int64_t i = 1; i <= n; i++) {
    cin >> ar[i];
    mx = max(mx, ar[i]);
    mn = min(mn, ar[i]);
  }
  for (int64_t i = 1; i <= n; i++) ar[i] = mx - ar[i];
  if (k % 2 == 0) {
    mn = mx - mn;
    for (int64_t i = 1; i <= n; i++) ar[i] = mn - ar[i];
  }
  for (int64_t i = 1; i <= n; i++) cout << ar[i] << " ";
  cout << endl;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int64_t t;
  cin >> t;
  while (t--) solve();
}
