#include <bits/stdc++.h>
using namespace std;
string yes = "YES", no = "NO";
void solve() {
  long long n, k;
  scanf("%lli%lli", &n, &k);
  long long qwe = n - k + 1;
  long long rty = n - 2 * k + 2;
  if (qwe > 0 and qwe % 2 == 1) {
    cout << yes << endl;
    for (int i = 0; i < k - 1; i++) {
      printf("1 ");
    }
    printf("%lli\n", qwe);
    return;
  }
  if (rty > 0 && rty % 2 == 0) {
    cout << yes << endl;
    for (int i = 0; i < k - 1; i++) {
      printf("2 ");
    }
    printf("%lli\n", rty);
    return;
  }
  cout << no << endl;
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) solve();
}
