#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops", "omit-frame-pointer", "inline")
#pragma GCC option("arch=native", "tune=native", "no-zero-upper")
#pragma GCC target("avx2")
using namespace std;
long long dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
long long dx[] = {-1, -1, 0, 1, 1, 1, 0, -1};
const long long maxn = 1e5;
const long long OO = 1e18;
const long long mod = 1e9 + 7;
const long double PI = acos(-1);
void maxself(long long &a, long long b) { a = max(a, b); }
void minself(long long &a, long long b) { a = min(a, b); }
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    vector<long long> v(n);
    long long mx = -OO;
    for (long long i = 0; i < n; i++) cin >> v[i], mx = max(mx, v[i]);
    if (k % 2)
      k = 1;
    else
      k = 2;
    while (k--) {
      long long nmx = -OO;
      for (long long i = 0; i < n; i++) {
        v[i] = mx - v[i];
        nmx = max(nmx, v[i]);
      }
      mx = nmx;
    }
    for (auto x : v) cout << x << ' ';
    cout << "\n";
  }
  return 0;
}
