#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  long long int t, n, i, j, k, a = 0;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    if ((n - k + 1) > 0 && (n - k + 1) % 2 == 1) {
      cout << "YES" << endl;
      for (i = 0; i < k - 1; i++)
        cout << "1"
             << " ";
      cout << n - k + 1 << endl;
    } else if ((2 * (k - 1)) < n && ((n - (2 * (k - 1))) % 2 == 0)) {
      cout << "YES" << endl;
      for (i = 0; i < k - 1; i++)
        cout << "2"
             << " ";
      cout << n - (2 * (k - 1)) << endl;
    } else
      cout << "NO" << endl;
  }
}
