#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
void chmin(T &a, const T &b) noexcept {
  if (b < a) a = b;
}
template <class T>
void chmax(T &a, const T &b) noexcept {
  if (a < b) a = b;
}
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &...args) {
  cout << x << " ";
  debug_out(args...);
}
int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int t;
  cin >> t;
  for (int i_ = 0; i_ < (t); ++i_) {
    ll n, k;
    cin >> n >> k;
    if ((n % 2 == 1 && k % 2 == 0) || (k > n)) {
      cout << "NO\n";
      continue;
    }
    if (n % 2 == 0) {
      if (k % 2 == 1) {
        ll x = n / k;
        if (x % 2 == 1) x--;
        if (x == 0 || (n - k * x) % 2 != 0) {
          cout << "NO\n";
          continue;
        }
        cout << "YES\n";
        vector<ll> ans(k, x);
        ans[0] += n - k * x;
        for (int i = 0; i < (k); ++i) {
          cout << ans[i] << " ";
        }
      } else {
        ll x = n / k;
        cout << "YES\n";
        vector<ll> ans(k, x);
        ans[0] += n - k * x;
        for (int i = 0; i < (k); ++i) {
          cout << ans[i] << " ";
        }
      }
    } else {
      ll x = n / k;
      if (x % 2 == 0) x--;
      if (x == 0 || (n - k * x) % 2 != 0) {
        cout << "NO\n";
        continue;
      }
      cout << "YES\n";
      vector<ll> ans(k, x);
      ans[0] += n - k * x;
      for (int i = 0; i < (k); ++i) {
        cout << ans[i] << " ";
      }
    }
    cout << endl;
  }
  return 0;
}
