#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, k;
  cin >> t;
  while (t-- && cin >> n >> k) {
    if ((n & 1 && k % 2 == 0) || k > n) {
      cout << "NO\n";
      continue;
    }
    if (n % 2 == 0 && k & 1) {
      if (n - 2 * (k - 1) <= 0)
        cout << "NO\n";
      else {
        cout << "YES\n";
        for (int i = 1; i < k; i++) cout << 2 << " ";
        cout << n - 2 * (k - 1) << endl;
      }
      continue;
    }
    cout << "YES\n";
    for (int i = 1; i < k; i++) cout << 1 << " ";
    cout << n - (k - 1) << endl;
  }
  return 0;
}
