#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T bigMod(T p, T e, T M) {
  long long ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return (T)ret;
}
template <class T>
inline T modInverse(T a, T M) {
  return bigMod(a, M - 2, M);
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T lcm(T a, T b) {
  a = abs(a);
  b = abs(b);
  return (a / gcd(a, b)) * b;
}
template <class T>
inline string int2String(T a) {
  ostringstream str;
  str << a;
  return str.str();
}
template <class T>
inline T string2int(string a) {
  stringstream str(a);
  T b;
  str >> b;
  return b;
}
template <class T>
inline void read(T& r) {
  r = 0;
  int f = 1;
  char ch = getchar();
  while (ch < '0' or ch > '9') {
    f = (ch == '-' ? -1 : 1), ch = getchar();
  }
  while (ch >= '0' and ch <= '9') {
    r = r * 10 + ch - '0', ch = getchar();
  }
  r *= f;
}
const int dr[] = {0, 1, 0, -1, -1, 1, 1, -1, -2, -2, 2, 2, -1, -1, 1, 1};
const int dc[] = {1, 0, -1, 0, 1, 1, -1, -1, -1, 1, -1, 1, -2, 2, -2, 2};
long long a[200005], b[200005];
int main() {
  int t;
  long long n, k;
  scanf("%d", &t);
  while (t--) {
    scanf("%lld %lld", &n, &k);
    long long mx = INT_MIN, mx1 = INT_MIN;
    for (int i = int(0); i < int(n); i++) {
      scanf("%lld", &a[i]);
      mx = max(mx, a[i]);
    }
    for (int i = int(0); i < int(n); i++) {
      b[i] = mx - a[i];
      mx1 = max(mx1, b[i]);
    }
    for (int i = int(0); i < int(n); i++) {
      a[i] = mx1 - b[i];
    }
    if (k % 2 == 0) {
      for (int i = int(0); i < int(n); i++) {
        printf("%d ", a[i]);
      }
    } else {
      for (int i = int(0); i < int(n); i++) {
        printf("%d ", b[i]);
      }
    }
    puts("");
  }
  return 0;
}
