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