#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    if (k > n)
      cout << "NO";
    else {
      vector<int> v1(k - 1, 1);
      vector<int> v2(k - 1, 2);
      int d1 = n - ((k - 1) * 1);
      int d2 = n - ((k - 1) * 2);
      if (d1 % 2 == 1 && d1 > 0) {
        cout << "YES" << endl;
        v1.push_back(d1);
        for (auto x : v1) cout << x << " ";
      } else if (d2 % 2 == 0 && d2 > 0) {
        cout << "YES" << endl;
        v2.push_back(d2);
        for (auto x : v2) cout << x << " ";
      } else {
        cout << "NO";
      }
    }
    cout << endl;
  }
}
