#include <bits/stdc++.h>
using namespace std;
bool prime[1000001];
void seive() {
  memset(prime, true, sizeof(prime));
  prime[0] = false;
  prime[1] = false;
  for (int i = 2; i * i <= 1000001; i++) {
    if (prime[i]) {
      for (int j = i * i; j <= 1000001; j += i) {
        prime[j] = false;
      }
    }
  }
}
void solve() {
  long long int n, k;
  cin >> n >> k;
  long long int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long int maxx = *max_element(a, a + n);
  for (long long int i = 0; i < n; i++) {
    a[i] = maxx - a[i];
  }
  long long int maxx2 = *max_element(a, a + n);
  if (n == 1) {
    cout << 0 << endl;
  } else {
    if (k % 2 == 1) {
      for (int i = 0; i < n; i++) {
        cout << a[i] << " ";
      }
    } else {
      for (int i = 0; i < n; i++) {
        cout << maxx2 - a[i] << " ";
      }
    }
  }
  cout << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
