#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    if (k > n) {
      cout << "NO\n";
      continue;
    }
    int t1 = n;
    int flag1 = 0;
    int flag2 = 0;
    if ((n - (k - 1) > 0)) {
      if ((n - (k - 1)) % 2 != 0) flag1 = 1;
    }
    if ((n - 2 * (k - 1) > 0)) {
      if ((n - 2 * (k - 1)) % 2 == 0) flag2 = 1;
    }
    if (flag1 == 1) {
      cout << "YES\n";
      for (int i = 1; i <= (k - 1); i++) {
        cout << "1 ";
      }
      cout << n - (k - 1) << "\n";
    } else if (flag2 == 1) {
      cout << "YES\n";
      for (int i = 1; i <= (k - 1); i++) {
        cout << "2 ";
      }
      cout << n - 2 * (k - 1) << "\n";
    } else {
      cout << "NO\n";
    }
  }
}
