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