#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n, k, d = -1000000000;
    cin >> n >> k;
    long long a[n + 9];
    vector<long long> b, c;
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
      d = max(d, a[i]);
    }
    long long x = -1000000000;
    for (long long i = 0; i < n; i++) {
      long long e = d - a[i];
      b.push_back(e);
      x = max(x, e);
    }
    if (k % 2) {
      for (long long i = 0; i < b.size(); i++) cout << b[i] << " ";
      cout << endl;
    } else {
      for (long long i = 0; i < b.size(); i++) {
        long long f = x - b[i];
        cout << f << " ";
      }
      cout << endl;
    }
  }
  return 0;
}
