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