#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    int a[n];
    int ma = INT_MIN;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (a[i] > ma) ma = a[i];
    }
    int m2 = INT_MIN;
    vector<int> v1, v2;
    for (int i = 0; i < n; i++) {
      a[i] = ma - a[i];
      if (m2 < a[i]) m2 = a[i];
      v1.push_back(a[i]);
    }
    for (int i = 0; i < n; i++) {
      a[i] = m2 - a[i];
    }
    if (k % 2) {
      for (int i = 0; i < v1.size(); i++) cout << v1[i] << " ";
      cout << endl;
    } else {
      for (int i = 0; i < n; i++) cout << a[i] << " ";
      cout << endl;
    }
  }
}
