#include <bits/stdc++.h>
using namespace std;
class BSameParitySummands {
 public:
  void solve(std::istream &in, std::ostream &out) {
    int t;
    in >> t;
    vector<int> v;
    for (int i = 0; i < t; i++) {
      int n, k;
      in >> n >> k;
      int rest = k - 1;
      if (n - rest * 2 > 0 && (n - rest * 2) % 2 == 0) {
        out << "YES\n";
        for (int j = 0; j < k - 1; j++) {
          out << "2 ";
        }
        out << n - (k - 1) * 2 << "\n";
        continue;
      }
      if (n - rest > 0 && (n - rest) % 2 != 0) {
        out << "YES\n";
        for (int j = 0; j < k - 1; j++) {
          out << "1 ";
        }
        out << n - (k - 1) << "\n";
        continue;
      }
      out << "NO\n";
    }
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  BSameParitySummands solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}
