#include <bits/stdc++.h>
using namespace std;
long long max(long long a, long long b) {
  if (a > b) return a;
  return b;
}
long long min(long long a, long long b) {
  if (a < b) return a;
  return b;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    long long a[n];
    long long mi = 1e10;
    long long ma = -1e10;
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
      mi = min(a[i], mi);
      ma = max(a[i], ma);
    }
    if (k % 2 == 1) {
      for (long long i = 0; i < n; i++) {
        cout << ma - a[i] << " ";
      }
      cout << endl;
    } else {
      for (long long i = 0; i < n; i++) {
        cout << a[i] - mi << " ";
      }
      cout << endl;
    }
  }
}
