#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    long long a[n];
    long long maximum = -999999999999999999;
    int i;
    vector<int> v, v2;
    for (i = 0; i < n; i++) {
      cin >> a[i];
      maximum = max(maximum, a[i]);
    }
    if (n == 1) {
      cout << 0 << endl;
      continue;
    }
    long long maximum2 = -999999999999999999;
    for (i = 0; i < n; i++) {
      v.push_back(maximum - a[i]);
      maximum2 = max(maximum2, (maximum - a[i]));
    }
    for (i = 0; i < v.size(); i++) {
      v2.push_back(maximum2 - v[i]);
    }
    if (k % 2 != 0) {
      for (i = 0; i < v.size(); i++) {
        cout << v[i] << " ";
      }
      cout << endl;
    } else {
      for (i = 0; i < v2.size(); i++) {
        cout << v2[i] << " ";
      }
      cout << endl;
    }
    v.clear();
    v2.clear();
  }
}
