#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
constexpr long long mod = 998244353;
constexpr long long inf = 3e18;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    if (2 * k <= n && (n - 2 * k) % 2 == 0) {
      cout << "YES\n";
      for (long long i = 0; i < k - 1; i++) cout << "2 ";
      cout << n - 2 * (k - 1) << "\n";
    } else if (k <= n && (n - k) % 2 == 0) {
      cout << "YES\n";
      for (long long i = 0; i < k - 1; i++) cout << "1 ";
      cout << n - (k - 1) << "\n";
    } else
      cout << "NO\n";
  }
}
