#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    if (k > n) {
      cout << "NO\n";
      continue;
    }
    if ((n - k + 1) % 2 == 1) {
      cout << "YES\n";
      cout << n - k + 1 << " ";
      k--;
      while (k--) cout << 1 << " ";
      cout << "\n";
    } else if ((n - (k - 1) * 2) % 2 == 0 && (n - (k - 1) * 2) > 0) {
      cout << "YES\n";
      cout << (n - (k - 1) * 2) << " ";
      k--;
      while (k--) cout << 2 << " ";
      cout << "\n";
    } else {
      cout << "NO\n";
    }
  }
  return 0;
}
