#include <bits/stdc++.h>
int main() {
  int t, n, k;
  scanf("%d", &t);
  while (t--) {
    scanf("%d %d", &n, &k);
    if (k > n)
      goto cnt;
    else if ((n + k) % 2 == 0) {
      printf("YES\n");
      n -= (k - 1);
      while (--k) printf("1 ");
      printf("%d\n", n);
    } else if ((n % 2 == 0) and (n / 2 >= k)) {
      printf("YES\n");
      n -= (k - 1) * 2;
      while (--k) printf("2 ");
      printf("%d\n", n);
    } else
    cnt:
      printf("NO\n");
  }
}
