#include <bits/stdc++.h>
using namespace std;
const long long mx = 200007;
long long a[mx];
long long solve(long long n) {
  bool flag = false;
  long long x = a[0];
  for (long long i = 1; i < n; i++)
    if (x != a[i]) {
      flag = true;
      break;
    }
  if (flag)
    return 1;
  else
    return n;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t, n, k;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    long long mx = INT_MIN;
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
      mx = max(mx, a[i]);
    }
    if (k % 2) {
      for (long long i = 0; i < n; i++) {
        a[i] = mx - a[i];
      }
    } else {
      long long mx1 = INT_MIN;
      for (long long i = 0; i < n; i++) {
        a[i] = mx - a[i];
        mx1 = max(mx1, a[i]);
      }
      for (long long i = 0; i < n; i++) a[i] = mx1 - a[i];
    }
    for (long long i = 0; i < n; i++) cout << a[i] << " ";
    cout << "\n";
  }
  return 0;
}
