#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio();
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    k %= 2;
    vector<long long> a(n);
    vector<long long> mx(n);
    for (int i = 0; i < n; i++) {
      long long x;
      cin >> x;
      a[i] = x;
      mx[i] = x;
    }
    sort(mx.rbegin(), mx.rend());
    int d = mx[0];
    if (k == 0) {
      for (int i = 0; i < n; i++) {
        a[i] = d - a[i];
        mx[i] = a[i];
      }
      sort(mx.rbegin(), mx.rend());
      for (int i = 0; i < n; i++) {
        a[i] = mx[0] - a[i];
      }
    } else {
      for (int i = 0; i < n; i++) {
        a[i] = mx[0] - a[i];
      }
    }
    for (auto c : a) {
      cout << c << " ";
    }
    cout << "\n";
  }
  return 0;
}
