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