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