#include <bits/stdc++.h>
using namespace std;
void mainSolve() {
  long long int n;
  cin >> n;
  long long int k;
  cin >> k;
  vector<long long int> v(n);
  for (long long int i = 0; i < n; i++) cin >> v[i];
  ;
  long long int d = max_element(v.begin(), v.end()) - v.begin();
  long long int val = v[d];
  for (int i = 0; i < n; i++) v[i] = val - v[i];
  k--;
  if (k % 2 == 0) {
    for (long long int i = 0; i < v.size(); ++i) cout << v[i] << " ";
    cout << '\n';
    return;
  }
  d = max_element(v.begin(), v.end()) - v.begin();
  val = v[d];
  for (int i = 0; i < n; i++) v[i] = val - v[i];
  for (long long int i = 0; i < v.size(); ++i) cout << v[i] << " ";
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    mainSolve();
  }
  return 0;
}
