1
2 1
-2 -3
 3
1 1
1
5 4
5 -1 4 2 0
1 2
69
 1
5 1
-5 -4 -3 -2 -1
 1
2 1
-6 -9
 1
1 398708496844866113
959414461
 1
2 1
-5 -4
 2
3 1
-1 -2 0
3 2
-1 -2 0
 1
5 1
-1 -2 -3 -4 -5
 1
2 1
-1000000000 -1000000000
 1
2 1
-199 -191
 1
1 1
-1000
 1
2 1
-5 -5
 1
5 5
-999999995 -999999996 -999999997 -999999998 -999999999
 1
3 1
-4 -5 -6
 1
1 1
-1
 1
3 1
-3 -4 -5
 1
3 1
-1000000000 -1000000000 -1000000000
 1
2 1
-10 -11
 1
3 3
-100 -100 -100
 1
3 1
-1 -2 -3
 1
5 5
-10 -9 -8 -7 -6
 1
4 1
-1 -1 -1 -1
 1
2 1
-1 -2
 1
3 999
1000000000 -1000000000 -31
 5
20 809014
289 -254 1 -109 -167 93 23 -37 -31 -109 204 59 296 49 132 0 -28 35 -197 -266
20 458494
113 218 -292 -298 179 258 -257 -20 296 76 -145 93 -282 -261 -159 -45 255 -107 171 63
14 876161
69 74 12 2 177 -113 103 93 38 -48 282 169 205 145
26 731742
76 190 -227 -81 -293 243 -122 -122 252 16 -88 243 -216 -275 -267 188 144 -245 -117 -244 -259 281 -273 -206 112 -51
20 327039
42 133 231 128 19 181 -137 193 136 75 -203 55 37 -155 -219 182 -178 -280 2 132
 4
6 4
219 57 -58 230 173 177
2 4
266 176
3 2
134 -190 202
5 69
-1000000000 -1000000000 1000000000 0 1000000000
 1
5 1
-9 -8 -7 -6 -5
 1
3 1
-1 -4 -10
 1
5 3
-4 -5 -6 -7 -8
 1
2 3
-3 -3
 1
5 1000000000000000000
-5 -4 -3 -2 -1

0 1  
 0  
6 0 5 3 1  
0  
 4 3 2 1 0  
 0 3  
 0  
 1 0  
 1 2 0  
1 0 2  
 0 1 2 3 4  
 0 0  
 8 0  
 0  
 0 0  
 0 1 2 3 4  
 0 1 2  
 0  
 0 1 2  
 0 0 0  
 0 1  
 0 0 0  
 0 1 2  
 4 3 2 1 0  
 0 0 0 0  
 0 1  
 0 2000000000 1000000031  
 555 12 267 157 99 359 289 229 235 157 470 325 562 315 398 266 238 301 69 0  
411 516 6 0 477 556 41 278 594 374 153 391 16 37 139 253 553 191 469 361  
213 208 270 280 105 395 179 189 244 330 0 113 77 137  
369 483 66 212 0 536 171 171 545 309 205 536 77 18 26 481 437 48 176 49 34 574 20 87 405 242  
189 98 0 103 212 50 368 38 95 156 434 176 194 386 450 49 409 511 229 99  
 277 115 0 288 231 235  
90 0  
324 0 392  
2000000000 2000000000 0 1000000000 0  
 4 3 2 1 0  
 0 3 9  
 0 1 2 3 4  
 0 0  
 0 1 2 3 4  

#include <bits/stdc++.h>
using namespace std;
class BigInt {
 public:
  int sign;
  string s;
  BigInt() : s("") {}
  BigInt(string x) { *this = x; }
  BigInt(int x) { *this = to_string(x); }
  BigInt negative() {
    BigInt x = *this;
    x.sign *= -1;
    return x;
  }
  BigInt normalize(int newSign) {
    for (int a = s.size() - 1; a > 0 && s[a] == '0'; a--)
      s.erase(s.begin() + a);
    sign = (s.size() == 1 && s[0] == '0' ? 1 : newSign);
    return *this;
  }
  void operator=(string x) {
    int newSign = (x[0] == '-' ? -1 : 1);
    s = (newSign == -1 ? x.substr(1) : x);
    reverse(s.begin(), s.end());
    this->normalize(newSign);
  }
  bool operator==(const BigInt &x) const {
    return (s == x.s && sign == x.sign);
  }
  bool operator<(const BigInt &x) const {
    if (sign != x.sign) return sign < x.sign;
    if (s.size() != x.s.size())
      return (sign == 1 ? s.size() < x.s.size() : s.size() > x.s.size());
    for (int a = s.size() - 1; a >= 0; a--)
      if (s[a] != x.s[a]) return (sign == 1 ? s[a] < x.s[a] : s[a] > x.s[a]);
    return false;
  }
  bool operator<=(const BigInt &x) const { return (*this < x || *this == x); }
  bool operator>(const BigInt &x) const {
    return (!(*this < x) && !(*this == x));
  }
  bool operator>=(const BigInt &x) const { return (*this > x || *this == x); }
  BigInt operator+(BigInt x) {
    BigInt curr = *this;
    if (curr.sign != x.sign) return curr - x.negative();
    BigInt res;
    for (int a = 0, carry = 0; a < s.size() || a < x.s.size() || carry; a++) {
      carry += (a < curr.s.size() ? curr.s[a] - '0' : 0) +
               (a < x.s.size() ? x.s[a] - '0' : 0);
      res.s += (carry % 10 + '0');
      carry /= 10;
    }
    return res.normalize(sign);
  }
  BigInt operator-(BigInt x) {
    BigInt curr = *this;
    if (curr.sign != x.sign) return curr + x.negative();
    int realSign = curr.sign;
    curr.sign = x.sign = 1;
    if (curr < x) return ((x - curr).negative()).normalize(-realSign);
    BigInt res;
    for (int a = 0, borrow = 0; a < s.size(); a++) {
      borrow = (curr.s[a] - borrow - (a < x.s.size() ? x.s[a] : '0'));
      res.s += (borrow >= 0 ? borrow + '0' : borrow + '0' + 10);
      borrow = (borrow >= 0 ? 0 : 1);
    }
    return res.normalize(realSign);
  }
  BigInt operator*(BigInt x) {
    BigInt res("0");
    for (int a = 0, b = s[a] - '0'; a < s.size(); a++, b = s[a] - '0') {
      while (b--) res = (res + x);
      x.s.insert(x.s.begin(), '0');
    }
    return res.normalize(sign * x.sign);
  }
  BigInt operator/(BigInt x) {
    if (x.s.size() == 1 && x.s[0] == '0') x.s[0] /= (x.s[0] - '0');
    BigInt temp("0"), res;
    for (int a = 0; a < s.size(); a++) res.s += "0";
    int newSign = sign * x.sign;
    x.sign = 1;
    for (int a = s.size() - 1; a >= 0; a--) {
      temp.s.insert(temp.s.begin(), '0');
      temp = temp + s.substr(a, 1);
      while (!(temp < x)) {
        temp = temp - x;
        res.s[a]++;
      }
    }
    return res.normalize(newSign);
  }
  BigInt operator%(BigInt x) {
    if (x.s.size() == 1 && x.s[0] == '0') x.s[0] /= (x.s[0] - '0');
    BigInt res("0");
    x.sign = 1;
    for (int a = s.size() - 1; a >= 0; a--) {
      res.s.insert(res.s.begin(), '0');
      res = res + s.substr(a, 1);
      while (!(res < x)) res = res - x;
    }
    return res.normalize(sign);
  }
  string toString() const {
    string ret = s;
    reverse(ret.begin(), ret.end());
    return (sign == -1 ? "-" : "") + ret;
  }
  BigInt toBase10(int base) {
    BigInt exp(1), res("0"), BASE(base);
    for (int a = 0; a < s.size(); a++) {
      int curr = (s[a] < '0' || s[a] > '9' ? (toupper(s[a]) - 'A' + 10)
                                           : (s[a] - '0'));
      res = res + (exp * BigInt(curr));
      exp = exp * BASE;
    }
    return res.normalize(sign);
  }
  BigInt toBase10(int base, BigInt mod) {
    BigInt exp(1), res("0"), BASE(base);
    for (int a = 0; a < s.size(); a++) {
      int curr = (s[a] < '0' || s[a] > '9' ? (toupper(s[a]) - 'A' + 10)
                                           : (s[a] - '0'));
      res = (res + ((exp * BigInt(curr) % mod)) % mod);
      exp = ((exp * BASE) % mod);
    }
    return res.normalize(sign);
  }
  string convertToBase(int base) {
    BigInt ZERO(0), BASE(base), x = *this;
    string modes = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    if (x == ZERO) return "0";
    string res = "";
    while (x > ZERO) {
      BigInt mod = x % BASE;
      x = x - mod;
      if (x > ZERO) x = x / BASE;
      res = modes[stoi(mod.toString())] + res;
    }
    return res;
  }
  BigInt toBase(int base) { return BigInt(this->convertToBase(base)); }
  friend ostream &operator<<(ostream &os, const BigInt &x) {
    os << x.toString();
    return os;
  }
};
void solve() {
  int n, k;
  cin >> n >> k;
  string s;
  BigInt b[n];
  BigInt d = BigInt("-1000000000000000007");
  for (int i = 0; i < n; i++) {
    cin >> s;
    b[i] = BigInt(s);
    if (b[i] > d) d = b[i];
  }
  if (!k) {
    for (int i = 0; i < n; i++) {
      cout << b[i] << " ";
    }
  } else if (k == 1) {
    for (int i = 0; i < n; i++) {
      BigInt res = d - b[i];
      cout << res.toString() << " ";
    }
  } else {
    bool con = true;
    int i = 1;
    while (con && i <= k) {
      con = false;
      BigInt nex = BigInt("-1000000000000000007");
      for (int i = 0; i < n; i++) {
        BigInt res = d - b[i];
        if (res < 0) con = true;
        if (res > nex) nex = res;
        b[i] = res;
      }
    }
    for (int i = 0; i < n; i++) cout << b[i].toString() << " ";
  }
  cout << "\n";
}
int main() {
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
