#include <bits/stdc++.h>
using namespace std;
long long N, M, K, R, l, r, A, B, X, Y, Z, C, D, Q, a, b, c, d, i, j, k, first,
    mx, ans, cnt, T, P;
void solve() {
  cin >> N >> K;
  long long A[N];
  long long lar = INT_MIN, sma = INT_MAX;
  for (long long int i = 0; i < N; i++) {
    cin >> A[i];
    lar = max(lar, A[i]);
    sma = min(sma, A[i]);
  }
  for (long long int i = 0; i < N; i++) {
    A[i] = lar - A[i];
  }
  if (K % 2 == 0) {
    for (long long int i = 0; i < N; i++) {
      A[i] = lar - sma - A[i];
    }
  }
  for (long long int i = 0; i < N; i++) {
    cout << A[i] << " ";
  }
  cout << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
