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