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