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