#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, k;
  cin >> n >> k;
  int odd_others = (k - 1);
  int even_others = (k - 1) * 2;
  int i;
  if ((n - even_others > 0) && (n - even_others) % 2 == 0) {
    cout << "YES\n";
    cout << n - even_others << " ";
    for (i = 1; i <= k - 1; i++) {
      cout << 2 << " ";
    }
  } else if ((n - odd_others > 0) && (n - odd_others) % 2 != 0) {
    cout << "YES\n";
    cout << n - odd_others << " ";
    for (i = 1; i <= k - 1; i++) {
      cout << 1 << " ";
    }
  } else {
    cout << "NO";
  }
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
