#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, k;
  cin >> n >> k;
  int a[200001];
  int mx = -1000000001;
  int mn = 1000000001;
  for (int i = 0; (1 == 1 ? i <= n - 1 : i >= n - 1); i += 1) {
    cin >> a[i];
    mx = max(mx, a[i]);
    mn = min(mn, a[i]);
  }
  int mx2 = mx - mn;
  for (int i = 0; (1 == 1 ? i <= n - 1 : i >= n - 1); i += 1) {
    a[i] = mx - a[i];
    cout << (k % 2 == 0 ? mx2 - a[i] : a[i]) << " ";
  }
  cout << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
