#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  vector<int> vec;
  while (t--) {
    int n;
    int MAX = -1, MIN = -1;
    long long k;
    cin >> n >> k;
    vec.clear();
    for (int i = 0, a; i < n; i++) {
      cin >> a;
      if (!i)
        MAX = i, MIN = i;
      else {
        if (vec[MAX] < a) MAX = i;
        if (vec[MIN] > a) MIN = i;
      }
      vec.push_back(a);
    }
    if (vec[MIN] != 0) {
      k--;
      int val = vec[MAX];
      for (int i = 0; i < n; i++) {
        vec[i] = val - vec[i];
      }
      swap(MAX, MIN);
    }
    if (k % 2 == 1) {
      int val = vec[MAX];
      for (int i = 0; i < n; i++) {
        vec[i] = val - vec[i];
      }
    }
    for (auto x : vec) cout << x << " ";
    cout << endl;
  }
}
