#include <bits/stdc++.h>
int main(void) {
  using namespace std;
  ios_base::sync_with_stdio(false), cin.tie(nullptr);
  int T;
  cin >> T;
  for (int case_num = 1; case_num <= T; ++case_num) {
    int64_t n, k;
    cin >> n >> k;
    vector<int64_t> A;
    if (k > n)
      ;
    else if (n % 2 == k % 2) {
      A.resize(k);
      for (auto& a : A) a = 1;
      A[k - 1] = n - k + 1;
    } else if (n % 2 == 0 && k <= n / 2) {
      A.resize(k);
      for (auto& a : A) a = 2;
      A[k - 1] = n - (2 * (k - 1));
    }
    if (A.size() > 0) {
      cout << "YES\n";
      for (auto a : A) cout << a << ' ';
    } else
      cout << "NO";
    cout << '\n';
  }
  return 0;
}
