#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T;
  cin >> T;
  while (T--) {
    long long n, k;
    cin >> n >> k;
    vector<long long> a(n);
    for (long long &i : a) cin >> i;
    long long mx = *max_element(a.begin(), a.end());
    vector<long long> first(n);
    for (long long i = 0; i < n; i++) first[i] = mx - a[i];
    mx = *max_element(first.begin(), first.end());
    vector<long long> second(n);
    for (long long i = 0; i < n; i++) second[i] = mx - first[i];
    if (k & 1) {
      for (long long i : first) cout << i << " ";
    } else {
      for (long long i : second) cout << i << " ";
    }
    cout << endl;
  }
  return 0;
}
