#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tc;
  cin >> tc;
  while (tc--) {
    long long int n, k;
    cin >> n >> k;
    long long int a[n], m = INT_MIN;
    for (long long int i = 0; i < n; i++) {
      cin >> a[i];
      m = max(m, a[i]);
    }
    long long int ans[n];
    if (k & 1) {
      for (long long int i = 0; i < n; i++) cout << m - a[i] << " ";
    } else {
      long long int d = INT_MIN;
      for (long long int i = 0; i < n; i++) {
        a[i] = m - a[i];
        d = max(d, a[i]);
      }
      for (long long int i = 0; i < n; i++) cout << d - a[i] << " ";
    }
    cout << endl;
  }
  return 0;
}
