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