#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    long long a[n], b[n], c[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    long long d = -1e9;
    for (int i = 0; i < n; i++) d = max(d, a[i]);
    for (int i = 0; i < n; i++) b[i] = d - a[i];
    d = -1e9;
    for (int i = 0; i < n; i++) d = max(d, b[i]);
    for (int i = 0; i < n; i++) c[i] = d - b[i];
    if (k & 1) {
      for (int i = 0; i < n; i++) cout << b[i] << ' ';
      cout << '\n';
    } else {
      for (int i = 0; i < n; i++) cout << c[i] << ' ';
      cout << '\n';
    }
  }
  return 0;
}
