#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    long long k;
    vector<int> x;
    scanf("%d %lld", &n, &k);
    for (int i = 0; i < n; i++) {
      int a;
      scanf("%d", &a);
      x.push_back(a);
    }
    int minimum = INT_MAX;
    int maximum = INT_MIN;
    for (int i = 0; i < n; i++) {
      minimum = min(minimum, x[i]);
      maximum = max(maximum, x[i]);
    }
    int dist = maximum - minimum;
    bool inv = ((k % 2) == 1);
    for (int i = 0; i < n; i++) {
      x[i] = x[i] - minimum;
    }
    if (inv) {
      for (int i = 0; i < n; i++) {
        x[i] = dist - x[i];
      }
    }
    for (int i = 0; i < n; i++) {
      printf("%d ", x[i]);
    }
    printf("\n");
  }
  return 0;
}
