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