#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int j = 0; j < t; j++) {
    long long n, k;
    cin >> n >> k;
    long long l = -1000000000;
    long long u = -1000000000;
    long long z[200000];
    long long a[200000];
    long long h[200000];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
      u = max(a[i], u);
    }
    for (int i = 0; i < n; i++) {
      z[i] = u - a[i];
    }
    for (int i = 0; i < n; i++) {
      l = max(z[i], l);
    }
    for (int i = 0; i < n; i++) {
      h[i] = l - z[i];
    }
    for (int i = 0; i < n; i++) {
      if (k % 2 == 0) {
        cout << h[i] << " ";
      } else {
        cout << z[i] << " ";
      }
    }
    cout << endl;
  }
}
