#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("-ffloat-store")
#pragma GCC optimization("unroll-loops")
using namespace std;
const long long mod = 1e9 + 7, inf = 1e18;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long _;
  cin >> _;
  while (_--) {
    long long n, k;
    cin >> n >> k;
    long long a[n];
    for (long long i = 0; i < n; i++) cin >> a[i];
    if (k % 2) {
      long long x = *max_element(a, a + n);
      for (long long i = 0; i < n; i++) {
        a[i] = x - a[i];
      }
    } else {
      for (long long j = 0; j < 2; j++) {
        long long x = *max_element(a, a + n);
        for (long long i = 0; i < n; i++) {
          a[i] = x - a[i];
        }
      }
    }
    for (long long i = 0; i < n; i++) {
      cout << a[i] << " ";
    }
    cout << "\n";
  }
}
