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