#include <bits/stdc++.h>
using namespace std;
int main() {
  int test;
  cin >> test;
  for (int i = 0; i < test; i++) {
    int n, k;
    cin >> n >> k;
    if ((n % 2 != 0 && k % 2 == 0) || k > n)
      cout << "NO" << endl;
    else {
      if (n % 2 == 0) {
        if (k % 2 != 0) {
          if (k * 2 > n)
            cout << "NO" << endl;
          else {
            cout << "YES" << endl;
            for (int j = 0; j < k - 1; j++)
              cout << "2"
                   << " ";
            cout << n - (2 * (k - 1)) << endl;
          }
        } else {
          cout << "YES" << endl;
          for (int j = 0; j < k - 1; j++)
            cout << "1"
                 << " ";
          cout << n - (k - 1) << endl;
        }
      } else {
        cout << "YES" << endl;
        for (int j = 0; j < k - 1; j++)
          cout << "1"
               << " ";
        cout << n - (k - 1) << endl;
      }
    }
  }
}
