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