#include <bits/stdc++.h>
using namespace std;
void solver() {
  int n, k;
  cin >> n >> k;
  vector<int> v;
  if (k > n) {
    cout << "NO" << '\n';
    return;
  }
  if ((n & 1)) {
    if (!(k & 1)) {
      cout << "NO" << '\n';
      return;
    } else {
      for (int i = 0; i < k - 1 && n; ++i) {
        v.push_back(1);
        n -= 1;
      }
      if (n) {
        v.push_back(n);
      }
    }
  } else {
    if (k > n / 2 && (k & 1)) {
      cout << "NO" << '\n';
      return;
    }
    if (k & 1) {
      for (int i = 0; i < k - 1 && n; ++i) {
        v.push_back(2);
        n -= 2;
      }
      if (n) {
        v.push_back(n);
      }
    } else {
      for (int i = 0; i < k - 1 && n; ++i) {
        v.push_back(1);
        n -= 1;
      }
      if (n) {
        v.push_back(n);
      }
    }
  }
  cout << "YES" << '\n';
  for (int i = 0; i < k; ++i) {
    cout << v[i] << " ";
  }
  cout << '\n';
}
int main() {
  cin.tie(0);
  int tc;
  cin >> tc;
  while (tc--) {
    solver();
  }
  return 0;
}
