#include <bits/stdc++.h>
using namespace std;
void solve(long long test) {
  long long n, k;
  cin >> n >> k;
  if ((n - k + 1) % 2 == 1 && (n - k + 1) > 0) {
    cout << "YES\n";
    for (long long i = 0; i < k - 1; i++) {
      cout << 1 << " ";
    }
    cout << n - k + 1 << "\n";
    return;
  }
  if ((n - 2 * k + 2) % 2 == 0 && (n - 2 * k + 2) > 0) {
    cout << "YES\n";
    for (long long i = 0; i < k - 1; i++) {
      cout << 2 << " ";
    }
    cout << n - 2 * k + 2 << "\n";
    return;
  }
  cout << "NO\n";
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long t = 1;
  cin >> t;
  for (long long i = 1; i <= t; i++) {
    solve(i);
  }
  return 0;
}
