#include <bits/stdc++.h>
using namespace std;
int a[2 * 100000 + 100];
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long k;
    int n;
    cin >> n >> k;
    int maxn = -INT_MAX;
    int minn = INT_MAX;
    int maxnum;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      maxn = max(maxn, a[i]);
      minn = min(minn, a[i]);
    }
    maxnum = maxn - minn;
    if (k % 2) {
      for (int i = 1; i <= n; i++) printf("%d ", maxn - a[i]);
      cout << endl;
    } else {
      for (int i = 1; i <= n; i++) a[i] = maxn - a[i];
      for (int i = 1; i <= n; i++) printf("%d ", maxnum - a[i]);
      cout << endl;
    }
  }
  return 0;
}
