#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
void solve() {
  long long int n, k;
  cin >> n >> k;
  bool f = false;
  if ((n - k + 1) % 2 != 0 and (n - k + 1) > 0) {
    f = true;
    cout << "YES" << endl;
    for (long long int i = 0; i < (k - 1); ++i) {
      cout << 1 << " ";
    }
    cout << (n - k + 1) << endl;
  }
  if (f == false and (n - 2 * k + 2) > 0 and (n - 2 * k + 2) % 2 == 0) {
    f = true;
    cout << "YES" << endl;
    for (long long int i = 0; i < (k - 1); ++i) {
      cout << 2 << " ";
    }
    cout << (n - 2 * k + 2) << endl;
  }
  if (f == false) {
    cout << "NO" << endl;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int tc;
  cin >> tc;
  for (long long int i = 1; i <= tc; ++i) {
    solve();
  }
  return 0;
}
