#include <bits/stdc++.h>
using namespace std;
void solve();
void YN(bool b) {
  if (b) {
    cout << "YES"
         << "\n";
    ;
  } else {
    cout << "NO"
         << "\n";
    ;
  }
};
void yn(bool b) {
  if (b) {
    cout << "Yes"
         << "\n";
    ;
  } else {
    cout << "No"
         << "\n";
    ;
  }
};
void queries() {
  int n;
  cin >> n;
  while (n--) solve();
}
const int maxn = 200200;
void solve() {
  long long n, k;
  cin >> n >> k;
  vector<long long> arr(n);
  long long mx = INT_MIN;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    mx = max(mx, arr[i]);
  }
  if (k % 2 == 1) {
    for (int i = 0; i < n; i++) {
      cout << mx - arr[i] << " ";
    }
    cout << "\n";
    ;
  } else {
    long long mx2 = INT_MIN;
    for (int i = 0; i < n; i++) {
      arr[i] = mx - arr[i];
      mx2 = max(mx2, arr[i]);
    }
    for (int i = 0; i < n; i++) {
      cout << mx2 - arr[i] << " ";
    }
    cout << "\n";
    ;
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  queries();
  ;
  return 0;
}
