#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long t;
  cin >> t;
  while (t--) {
    long long i, j, n, m, k, x;
    cin >> n >> k;
    k = k % 2;
    vector<long long> v(n);
    for (i = 0; i < n; ++i) cin >> v[i];
    long long mi = *min_element(v.begin(), v.end());
    long long ma = *max_element(v.begin(), v.end());
    if (k == 0) {
      for (i = 0; i < n; ++i) v[i] = ma - v[i];
      ma = *max_element(v.begin(), v.end());
      for (i = 0; i < n; ++i) v[i] = ma - v[i];
    } else {
      for (i = 0; i < n; ++i) v[i] = ma - v[i];
    }
    for (i = 0; i < n; ++i) cout << v[i] << " ";
    cout << endl;
  }
  return 0;
}
