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