#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5, INF = 1e18 + 10, md = 1e9 + 7;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long takemod(long long a, long long mod) {
  a %= mod;
  if (a < 0) a += mod;
  return a;
}
long long fast_exp(long long base, long long expo, long long mod) {
  long long res = 1;
  while (expo > 0) {
    if (expo & 1) res = (res * base) % mod;
    base = (base * base) % mod;
    expo >>= 1;
  }
  return res;
}
long long modinv(long long a, long long mod) {
  return takemod(fast_exp(takemod(a, mod), mod - 2, mod), mod);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    vector<long long> a(n);
    long long mn = INF;
    long long mx = -INF;
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
      mx = max(mx, a[i]);
      mn = min(mn, a[i]);
    }
    if (k) {
      for (long long i = 0; i < n; i++) {
        if (k % 2) {
          a[i] = mx - a[i];
        } else {
          a[i] = a[i] - mn;
        }
      }
    }
    for (long long i = 0; i < n; i++) {
      cout << a[i] << " ";
    }
    cout << '\n';
  }
  return 0;
}
