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