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