#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const int INF = 1e9 + 7;
const long long INFll = 1e18;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
template <typename T>
T min(T a, T b, T c) {
  if (a > b) swap(a, b);
  if (b > c) swap(b, c);
  if (a > b) swap(a, b);
  return a;
}
void solve() {
  int n;
  long long k;
  cin >> n >> k;
  vector<int> arr(n);
  int mx = -INF;
  for (auto& i : arr) {
    cin >> i;
    mx = max(mx, i);
  }
  for (int i = 0; i < n; i++) {
    arr[i] = mx - arr[i];
  }
  k--;
  if (k & 1) {
    mx = -INF;
    for (int i = 0; i < n; i++) {
      mx = max(mx, arr[i]);
    }
    for (int i = 0; i < n; i++) {
      arr[i] = mx - arr[i];
    }
  }
  for (int i = 0; i < n; i++) {
    cout << arr[i] << " ";
  }
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin.sync_with_stdio(0);
  cout.tie(0);
  cout.sync_with_stdio(0);
  int q;
  cin >> q;
  while (q--) {
    solve();
  }
}
