#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, ops;
  cin >> n >> ops;
  vector<long long> a(n), op1(n), op2(n);
  for (auto &i : a) cin >> i;
  long long mx = *max_element(a.begin(), a.end());
  for (int i = 0; i < n; ++i) op1[i] = mx - a[i];
  mx = *max_element(op1.begin(), op1.end());
  for (int i = 0; i < n; ++i) op2[i] = mx - op1[i];
  if (ops & 1) {
    for (auto x : op1) cout << x << " ";
    cout << "\n";
  } else {
    for (auto x : op2) cout << x << " ";
    cout << "\n";
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
