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