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