#include <bits/stdc++.h>
using namespace std;
int main() {
  FILE *inF, *outF;
  inF = fopen("in", "r");
  outF = fopen("out", "w");
  inF = stdin;
  outF = stdout;
  int t;
  fscanf(inF, "%d", &t);
  while (t--) {
    int n;
    long long k;
    fscanf(inF, "%d %lld", &n, &k);
    int m = -1e9 - 1;
    int arr[200000];
    for (int i = 0; i < n; i++) {
      fscanf(inF, "%d", &arr[i]);
      m = max(m, arr[i]);
    }
    int nm = -1e9 - 1;
    for (int i = 0; i < n; i++) {
      arr[i] = m - arr[i];
      nm = max(nm, arr[i]);
    }
    if (k % 2 == 0) {
      for (int i = 0; i < n; i++) {
        arr[i] = nm - arr[i];
      }
    }
    for (int i = 0; i < n; i++) {
      fprintf(outF, "%d ", arr[i]);
    }
    fprintf(outF, "\n");
  }
  return 0;
}
