#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e5 + 5;
long long cnt[maxn];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    long long mm = -0x3f3f3f3f, mmm = -0x3f3f3f3f;
    for (long long i = 1; i <= n; i++) cin >> cnt[i], mm = max(mm, cnt[i]);
    for (long long i = 1; i <= n; i++) {
      cnt[i] = mm - cnt[i];
      mmm = max(mmm, cnt[i]);
    }
    if (k % 2 != 0) {
      for (long long i = 1; i <= n; i++) cout << cnt[i] << " ";
      cout << endl;
    } else {
      for (long long i = 1; i <= n; i++) {
        cnt[i] = mmm - cnt[i];
        cout << cnt[i] << " ";
      }
      cout << endl;
    }
  }
  return 0;
}
