#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    long long arr[n], arr1[n], arr2[n];
    long long F1 = INT_MIN, F2 = INT_MIN;
    for (int i = 0; i < n; ++i) {
      cin >> arr[i];
      F1 = max(F1, arr[i]);
    }
    for (int i = 0; i < n; ++i) {
      arr1[i] = F1 - arr[i];
      F2 = max(F2, arr1[i]);
    }
    for (int i = 0; i < n; ++i) {
      arr2[i] = F2 - arr1[i];
    }
    if ((k - 1) & 1) {
      for (int i = 0; i < n; ++i) {
        cout << arr2[i] << " ";
      }
    } else {
      for (int i = 0; i < n; ++i) {
        cout << arr1[i] << " ";
      }
    }
    cout << endl;
  }
  return 0;
}
