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