#include <bits/stdc++.h>
using namespace std;
using namespace chrono;
const long long int MOD = 1000000007;
const long long int MAXN = 1000005;
const long long int INF = 100000000000005;
void solve() {
  long long int n, k, flag = 0;
  cin >> n >> k;
  vector<long long int> a(n);
  for (long long int i = 0; i < n; ++i) cin >> a[i];
  long long int _max = *max_element(a.begin(), a.end());
  for (auto &itr : a) {
    itr = _max - itr;
  }
  --k;
  _max = *max_element(a.begin(), a.end());
  if (k == 0) {
    for (auto &itr : a) {
      cout << itr << " ";
    }
    cout << endl;
    return;
  }
  if (k & 1) {
    for (auto &itr : a) {
      cout << _max - itr << " ";
    }
    cout << endl;
  } else {
    for (auto &itr : a) {
      cout << itr << " ";
    }
    cout << endl;
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
