#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, k;
    cin >> n >> k;
    long long int arr[n], i;
    for (i = 0; i < n; i++) cin >> arr[i];
    if (k % 2) {
      long long int m = -1e9 - 7;
      for (i = 0; i < n; i++) m = max(m, arr[i]);
      for (i = 0; i < n; i++) arr[i] = m - arr[i];
    } else {
      long long int m = -1e9 - 7;
      for (i = 0; i < n; i++) m = max(m, arr[i]);
      for (i = 0; i < n; i++) arr[i] = m - arr[i];
      m = -1e9 - 7;
      for (i = 0; i < n; i++) m = max(m, arr[i]);
      for (i = 0; i < n; i++) arr[i] = m - arr[i];
    }
    for (i = 0; i < n; i++) cout << arr[i] << " ";
    cout << endl;
  }
  return 0;
}
