#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
const int N = 100005;
void solve() {
  long long n, k;
  cin >> n >> k;
  vector<long long> v(n);
  long long maxx = -(1ll << 60);
  for (long long i = 0; i <= n - 1; i++) cin >> v[i], maxx = max(maxx, v[i]);
  k--;
  long long mx = 0;
  for (long long i = 0; i <= n - 1; i++) {
    v[i] = maxx - v[i];
    mx = max(mx, v[i]);
  }
  if (k % 2 == 0) {
    for (long long i = 0; i <= n - 1; i++) cout << v[i] << " ";
  } else {
    for (long long i = 0; i <= n - 1; i++) cout << mx - v[i] << " ";
  }
  cout << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  cin >> TESTS;
  while (TESTS--) {
    solve();
  }
  return 0;
}
