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