#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    long long a[n];
    long long mx = INT_MIN;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      mx = max(mx, a[i]);
    }
    vector<long long> v;
    long long temp = INT_MIN;
    for (int i = 0; i < n; i++) {
      temp = max(temp, mx - a[i]);
      v.push_back(mx - a[i]);
    }
    if (k % 2) {
      for (int i = 0; i < n; i++) cout << mx - a[i] << " ";
      cout << endl;
    } else {
      for (int i = 0; i < n; i++) cout << temp - v[i] << " ";
      cout << endl;
    }
  }
  return 0;
}
