#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 1e9;
const long long N = 2e5 + 5;
long long ar[N];
void func(long long n) {
  long long mx = -1e9;
  for (long long i = 0; i < n; i++) mx = max(mx, ar[i]);
  for (long long i = 0; i < n; i++) ar[i] = mx - ar[i];
  return;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t_c_ = 1;
  cin >> t_c_;
  while (t_c_--) {
    long long n, k;
    cin >> n >> k;
    for (long long i = 0; i < n; i++) cin >> ar[i];
    func(n);
    k--;
    if (k & 1) func(n);
    for (long long i = 0; i < n; i++) cout << ar[i] << " ";
    cout << '\n';
  }
}
