#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    long long int n, k;
    cin >> n;
    cin >> k;
    if (k % 2 != 0)
      k = k % 2;
    else
      k = (k % 2) + 2;
    vector<int> a(n);
    for (auto &it : a) cin >> it;
    for (int i = 0; i < k; i++) {
      int d = *max_element(a.begin(), a.end());
      for (int i = 0; i < n; i++) {
        a[i] = d - a[i];
      }
    }
    for (auto it : a) cout << it << " ";
    cout << endl;
  }
}
