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