#include <bits/stdc++.h>
using namespace std;
void Main();
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int x;
  cin >> x;
  while (~cin.peek()) Main(), cin.get();
  return 0;
}
void Main() {
  int n, k;
  cin >> n >> k;
  if (n % 2 == 1 && k % 2 == 0)
    cout << "NO" << endl;
  else {
    if (n % 2 == 1 && k % 2 == 1) {
      if (n < k)
        cout << "NO" << endl;
      else {
        cout << "YES" << endl;
        for (int i = 0; i < k - 1; i++) cout << 1 << " ";
        cout << n - k + 1 << endl;
      }
    } else if (k % 2 == 1) {
      if (n < 2 * k)
        cout << "NO" << endl;
      else {
        cout << "YES" << endl;
        for (int i = 0; i < k - 1; i++) cout << 2 << " ";
        cout << n - (k - 1) * 2 << endl;
      }
    } else {
      if (n < k)
        cout << "NO" << endl;
      else {
        cout << "YES" << endl;
        for (int i = 0; i < k - 1; i++) cout << 1 << " ";
        cout << n - k + 1 << endl;
      }
    }
  }
}
