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