#include <bits/stdc++.h>
using namespace std;
long long int const mod = 1e9 + 7;
long long int const inf = 1e15 + 7;
long long int const mxn = 1e5 + 1;
inline void file() {}
int main() {
  file();
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, k, max1 = -1 * inf, mx = -1 * inf;
    cin >> n >> k;
    long long int a[n];
    vector<long long int> v, v1;
    for (long long int i = 0; i < n; i++) {
      cin >> a[i];
      mx = max(a[i], mx);
    }
    for (long long int i = 0; i < n; i++) {
      max1 = max(mx - a[i], max1);
      v.push_back(mx - a[i]);
    }
    for (long long int i = 0; i < n; i++) v1.push_back(max1 - v[i]);
    if (k & 1) {
      for (long long int x : v) cout << x << "\t";
      cout << "\n";
    } else {
      for (long long int x : v1) cout << x << "\t";
      cout << "\n";
    }
  }
}
