#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t, i, m, n, j, k, ans = 0, count = 0, tot = 0, flag = 0;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    if (n % 2 == 0 && k % 2 == 0) {
      if (k <= n) {
        cout << "YES\n";
        for (i = 0; i < k - 1; i++) {
          cout << "1 ";
        }
        cout << n - (k - 1) << "\n";
      } else {
        cout << "NO\n";
      }
    } else if (n % 2 == 0 && k % 2 == 1) {
      if (2 * k > n) {
        cout << "NO\n";
      } else {
        cout << "YES\n";
        for (i = 0; i < k - 1; i++) {
          cout << "2 ";
        }
        cout << n - 2 * (k - 1) << "\n";
      }
    } else if (n % 2 == 1 && (k % 2 == 0) || k > n) {
      cout << "NO\n";
    } else {
      cout << "YES\n";
      for (i = 0; i < k - 1; i++) {
        cout << "1 ";
      }
      cout << n - (k - 1) << "\n";
    }
  }
  return 0;
}
