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