#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("-O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    if ((n - k + 1) & 1 && (n - k + 1) >= 1) {
      cout << "YES\n";
      for (int i = 1; i < k; i++) {
        cout << 1 << " ";
      }
      cout << n - k + 1 << "\n";
    } else if ((n - 2 * (k - 1)) % 2 == 0 && (n - 2 * (k - 1)) >= 2) {
      cout << "YES\n";
      for (int i = 1; i < k; i++) {
        cout << 2 << " ";
      }
      cout << n - 2 * (k - 1) << "\n";
    } else {
      cout << "NO\n";
    }
  }
  return 0;
}
