#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    if (k > n) {
      cout << "NO" << endl;
      continue;
    }
    int odd_ones = k - 1;
    int odd_lastNum = n - (k - 1);
    if (odd_lastNum > 0 && odd_lastNum % 2 == 1) {
      cout << "YES" << endl;
      for (int i = 0; i < odd_ones; i++) {
        cout << 1 << " ";
      }
      cout << odd_lastNum << endl;
      continue;
    }
    int even_twos = k - 1;
    int even_lastNum = n - 2 * (k - 1);
    if (even_lastNum > 0 && even_lastNum % 2 == 0) {
      cout << "YES" << endl;
      for (int i = 0; i < k - 1; i++) {
        cout << 2 << " ";
      }
      cout << even_lastNum << endl;
      continue;
    }
    cout << "NO" << endl;
  }
  return 0;
}
