#include <bits/stdc++.h>
using namespace std;
long long modular(long long a, long long b, long long c) {
  if (b == 0) {
    return 1;
  }
  if (b % 2 == 0) {
    return modular(((a * a) % c), b / 2, c);
  } else {
    return ((a % c) * (modular(((a * a) % c), b / 2, c) % c)) % c;
  }
}
signed 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 (k > n) {
      cout << "NO"
           << "\n";
      continue;
    } else {
      bool possible = false;
      long long a = 1;
      long long b = n - (k - 1);
      if (b % 2 == 1) {
        cout << "YES"
             << "\n";
        for (long long i = 0; i < k - 1; i++) cout << 1 << " ";
        cout << b << "\n";
        continue;
      }
      a = 2;
      b = n - 2 * (k - 1);
      if (b > 0 && b % 2 == 0) {
        possible = true;
        cout << "YES"
             << "\n";
        for (long long i = 0; i < k - 1; i++) cout << 2 << " ";
        cout << b << "\n";
        continue;
      }
      cout << "NO"
           << "\n";
    }
  }
  return 0;
}
