#include <bits/stdc++.h>
using namespace std;
long long t, n, k, i, ma, ans, a[200001];
int main() {
  cin.tie(0), ios_base::sync_with_stdio(0);
  cin >> t;
  while (t--) {
    cin >> n >> k;
    if (k % 2)
      k = 1;
    else
      k = 2;
    for (i = 0; i < n; i++) cin >> a[i];
    while (k--) {
      ma = -9e18;
      for (i = 0; i < n; i++) ma = max(ma, a[i]);
      for (i = 0; i < n; i++) a[i] = ma - a[i];
    }
    for (i = 0; i < n; i++) cout << a[i] << " ";
    cout << "\n";
  }
  return 0;
}
