#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, a, b, c, d, i, j, k, l, n, m, x, y;
  cin >> t;
  while (t--) {
    cin >> n >> d;
    long long int s[n + 5];
    l = 0;
    for (i = 0; i < n; i++) {
      cin >> s[i];
    }
    vector<long long int> v, p;
    l = *max_element(s, s + n);
    for (i = 0; i < n; i++) {
      s[i] = l - s[i];
      v.push_back(s[i]);
    }
    k = *max_element(s, s + n);
    for (i = 0; i < n; i++) {
      s[i] = k - s[i];
      p.push_back(s[i]);
    }
    if (d % 2 != 0) {
      for (i = 0; i < n; i++) cout << v[i] << " ";
    } else if (d % 2 == 0) {
      for (i = 0; i < n; i++) cout << p[i] << " ";
    }
    v.clear();
    p.clear();
    cout << endl;
  }
}
