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