#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int r = 0; r < t; r++) {
    long long n, k, x, ma = -2 * 1e9 - 1;
    cin >> n >> k;
    vector<int> a;
    for (int i = 0; i < n; i++) {
      cin >> x;
      a.push_back(x);
      if (x > ma) {
        ma = x;
      }
    }
    for (int i = 0; i < a.size(); i++) {
      a[i] = ma - a[i];
    }
    if (k % 2 == 1) {
      for (int i = 0; i < a.size(); i++) {
        cout << a[i] << " ";
      }
      cout << endl;
    } else {
      ma = -2 * 1e9 - 1;
      for (int i = 0; i < n; i++) {
        if (a[i] > ma) {
          ma = a[i];
        }
      }
      for (int i = 0; i < a.size(); i++) {
        cout << ma - a[i] << " ";
      }
      cout << endl;
    }
  }
  return 0;
}
