#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, k;
  cin >> n >> k;
  long long int a[n];
  long long int h;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  h = *max_element(a, a + n);
  for (long long int i = 0; i < n; i++) {
    a[i] = h - a[i];
  }
  h = *max_element(a, a + n);
  if (k == 1) {
    for (long long int i = 0; i < n; i++) {
      cout << a[i] << " ";
    }
    cout << "\n";
  } else if (!(k % 2)) {
    for (long long int i = 0; i < n; i++) {
      cout << h - a[i] << " ";
    }
    cout << "\n";
  } else {
    for (long long int i = 0; i < n; i++) {
      a[i] = h - a[i];
    }
    h = *max_element(a, a + n);
    for (long long int i = 0; i < n; i++) {
      cout << h - a[i] << " ";
    }
    cout << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T;
  cin >> T;
  while (T--) {
    solve();
  }
  return 0;
}
