#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n, m;
  cin >> n >> m;
  if (m > n) {
    cout << "NO" << '\n';
    return;
  } else if (n % 2 == 0) {
    if (m <= n / 2) {
      cout << "YES" << '\n';
      for (long long int i = 0; i < m - 1; i++) cout << "2 ";
      cout << (n - 2 * (m - 1)) << '\n';
    } else if (m % 2 == 0) {
      cout << "YES" << '\n';
      for (long long int i = 0; i < m - 1; i++) cout << "1 ";
      cout << n - m + 1 << '\n';
    } else {
      cout << "NO" << '\n';
    }
  } else {
    if (m % 2 == 1) {
      cout << "YES" << '\n';
      for (long long int i = 0; i < m - 1; i++) cout << "1 ";
      cout << n - m + 1 << '\n';
    } else
      cout << "NO" << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
