#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e3 + 10;
char ss[maxn];
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n, k;
    scanf("%d%d", &n, &k);
    if (k > n)
      puts("NO");
    else {
      if ((n - (k - 1)) % 2 == 1) {
        puts("YES");
        for (int i = 1; i < k; i++) cout << 1 << " ";
        cout << n - k + 1 << endl;
      } else if ((n - (k - 1) * 2) % 2 == 0 && (n - (k - 1) * 2) > 0) {
        puts("YES");
        for (int i = 1; i < k; i++) cout << 2 << " ";
        cout << n - (k - 1) * 2 << endl;
      } else
        puts("NO");
    }
  }
}
