#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n, k, mx = -INT_MAX;
    cin >> n >> k;
    long long a[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      mx = max(mx, a[i]);
    }
    if (k == 0) {
      for (int i = 0; i < n; i++) cout << a[i] << " ";
    } else {
      if (k & 1)
        k = 1;
      else
        k = 2;
      for (int i = 1; i <= k; i++) {
        long long d = mx;
        mx = -INT_MAX;
        for (int i = 0; i < n; i++) {
          a[i] = d - a[i];
          mx = max(mx, a[i]);
        }
      }
      for (int i = 0; i < n; i++) cout << a[i] << " ";
    }
    cout << endl;
  }
}
