#include <bits/stdc++.h>
using namespace std;
using ULL = unsigned long long;
using LL = long long;
vector<long long> op(vector<long long> a) {
  long long d = -1000000000;
  long long n = a.size();
  for (int i = 0; i < n; ++i) {
    if (a[i] > d) d = a[i];
  }
  for (int i = 0; i < n; ++i) {
    a[i] = d - a[i];
  }
  return a;
}
int main() {
  ios_base::sync_with_stdio(0);
  int t;
  cin >> t;
  for (int x = 0; x < t; ++x) {
    long long n, k;
    cin >> n >> k;
    vector<long long> a(n, 0);
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    vector<long long> b = op(a);
    vector<long long> c = op(b);
    if (k % 2 == 1) {
      for (int i = 0; i < n; ++i) {
        cout << b[i] << ' ';
      }
    } else {
      for (int i = 0; i < n; ++i) {
        cout << c[i] << ' ';
      }
    }
    cout << endl;
  }
}
