#include <bits/stdc++.h>
using namespace std;
bool sortin(const pair<long long int, long long int> &e,
            const pair<long long int, long long int> &f) {
  return (e.first < f.first);
}
bool POT(long long int x) { return x && (!(x & (x - 1))); }
long long int i, j, k, l, m, n, p, q, r, a, b, c, x, y, z, ts, mn = 1e18,
                                                               mod = 1e9 + 7;
long long int ar[250002], br[250002], xr[250002];
int main() {
  {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  };
  cin >> ts;
  for (long long int test = 0; test < ts; test++) {
    cin >> n >> k;
    for (long long int i = 0; i <= n - 1; i++) cin >> ar[i];
    if (k % 2)
      k = 1;
    else
      k = 2;
    while (k--) {
      m = -1e18;
      for (long long int i = 0; i <= n - 1; i++) m = max(m, ar[i]);
      for (long long int i = 0; i <= n - 1; i++) ar[i] = m - ar[i];
    }
    for (long long int i = 0; i <= n - 1; i++) cout << ar[i], cout << ' ';
    cout << endl;
  }
}
