#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int T, n, a[N];
long long k;
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d%lld", &n, &k);
    if (k & 1)
      k = 1;
    else
      k = 2;
    for (int i = 1; i <= n; i++) scanf("%d", a + i);
    while (k--) {
      int maxi = -1e9;
      for (int i = 1; i <= n; i++)
        if (maxi < a[i]) maxi = a[i];
      for (int i = 1; i <= n; i++) a[i] = maxi - a[i];
    }
    for (int i = 1; i <= n; i++) printf("%d ", a[i]);
    puts("");
  }
}
