#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int n, k;
    cin >> n >> k;
    vector<int> v;
    while (n--) {
      int x;
      cin >> x;
      v.push_back(x);
    }
    int maxi = *max_element(v.begin(), v.end());
    int i = 0;
    while (i < v.size()) {
      v[i] = maxi - v[i];
      i++;
    }
    if (k % 2) {
      for (int j = 0; j < v.size(); j++) {
        cout << v[j] << " ";
      }
      cout << endl;
    } else {
      maxi = *max_element(v.begin(), v.end());
      i = 0;
      while (i < v.size()) {
        v[i] = maxi - v[i];
        i++;
      }
      for (int j = 0; j < v.size(); j++) {
        cout << v[j] << " ";
      }
      cout << endl;
    }
  }
  return 0;
}
