#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    if (n % 2 == 0) {
      long long a1 = n / 2;
      if (k > a1) {
        if (k % 2 == 1 || k > n) {
          cout << "NO\n";
          continue;
        }
        long long n1 = 1;
        long long n2 = 0;
        cout << "YES\n";
        for (long long i = 0; i < k - 1; i++) {
          cout << n1 << " ";
          n2 += 1;
        }
        n2 = n - n2;
        cout << n2 << "\n";
        continue;
      }
      cout << "YES\n";
      long long n1 = 2;
      long long n2 = 0;
      for (long long i = 0; i < k - 1; i++) {
        cout << n1 << " ";
        n2 = n2 + 2;
      }
      n2 = n - n2;
      cout << n2 << "\n";
    } else {
      if (k % 2 == 0 || k > n) {
        cout << "NO\n";
        continue;
      }
      long long n1 = 1;
      long long n2 = 0;
      cout << "YES\n";
      for (long long i = 0; i < k - 1; i++) {
        cout << n1 << " ";
        n2 += 1;
      }
      n2 = n - n2;
      cout << n2 << "\n";
    }
  }
}
