#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0)->sync_with_stdio(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    long long a[n];
    long long mx = -(int)1e9 - 1;
    long long mn = (int)1e9 + 1;
    for (long long i = 0; i < n; i++) {
      long long u;
      cin >> u;
      a[i] = u;
      mx = max(mx, u);
      mn = min(mn, u);
    }
    for (long long i = 0; i < n; i++) a[i] = mx - a[i];
    if (k % 2 == 1) {
      for (long long i : a) cout << i << " ";
    } else {
      mx = -(int)1e9 + 1;
      for (long long i = 0; i < n; i++) {
        mx = max(mx, a[i]);
      }
      for (long long i : a) cout << mx - i << " ";
    }
    cout << "\n";
  }
  return 0;
}
