#include <bits/stdc++.h>
using namespace std;
long long solve() {
  long long n, k, i = 0, a, b;
  cin >> n >> k;
  bool p = 0, q = 1;
  if (n % k == 0) {
    cout << "YES"
         << "\n";
    for (i = 0; i < k; i++) cout << n / k << " ";
    cout << "\n";
    return 0;
  }
  if (n % 2 == 0) {
    p = 0;
    b = n - 2 * k + 2;
  } else {
    p = 1;
    b = n - k + 1;
  }
  if (b < 1) q = 0;
  if (n < k || ((n % 2) && !(k % 2))) {
    cout << "NO"
         << "\n";
    return 0;
  }
  if (n < 2 * k && k % 2 == 0) {
    cout << "YES"
         << "\n";
    for (i = 0; i < k - 1; i++) cout << 1 << " ";
    cout << n - k + 1 << "\n";
  } else if (!q)
    cout << "NO"
         << "\n";
  else {
    cout << "YES"
         << "\n";
    for (i = 0; i < k - 1; i++) {
      if (p)
        cout << 1 << " ";
      else
        cout << 2 << " ";
    }
    cout << b << "\n";
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, tests = 1, prev = 0;
  cin >> tests;
  while (tests--) {
    solve();
  }
  return 0;
}
