#include <bits/stdc++.h>
int main() {
  int t;
  long long int n, k, max;
  scanf("%d", &t);
  while (t--) {
    scanf("%lld %lld", &n, &k);
    long long int a[n], b[n];
    for (long long int i = 0; i < n; i++) {
      scanf("%lld", &a[i]);
      if (i == 0) max = a[i];
      if (max < a[i]) max = a[i];
    }
    if (k == 0) {
      for (long long int i = 0; i < n; i++) printf("%lld ", a[i]);
      printf("\n");
    } else {
      for (long long int i = 0; i < n; i++) a[i] = max - a[i];
      for (long long int i = 0; i < n; i++) {
        if (i == 0) max = a[i];
        if (max < a[i]) max = a[i];
      }
      for (long long int i = 0; i < n; i++) b[i] = max - a[i];
      if (k % 2 == 1) {
        for (long long int i = 0; i < n; i++) printf("%lld ", a[i]);
        printf("\n");
      } else {
        for (long long int i = 0; i < n; i++) printf("%lld ", b[i]);
        printf("\n");
      }
    }
  }
}
