#include <bits/stdc++.h>
using namespace std;
long long int a[200005], pow2[64], n = 0;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, k, f = 0;
    ;
    cin >> n >> k;
    long long int a[n], ma = -1000000000000, mi = 0;
    for (long long int i = 0; i < n; i++) {
      cin >> a[i];
      ma = max(a[i], ma);
    }
    for (long long int i = 0; i < n; i++) {
      a[i] = ma - a[i];
      mi = max(mi, a[i]);
    }
    k--;
    if (k % 2 == 0) {
      for (long long int i = 0; i < n; i++) {
        cout << a[i] << ' ';
      }
    } else {
      for (long long int i = 0; i < n; i++) {
        cout << mi - a[i] << ' ';
      }
    }
    cout << '\n';
  }
}
