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