#include <bits/stdc++.h>
using namespace std;
const long long int Mod = 998244353;
const long long int mod = 1e9 + 7;
long long int Pow(long long int a, long long int b) {
  a = a % mod;
  long long int res = 1;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return (res % mod);
}
long long int modInverse(long long int a, long long int m) {
  return Pow(a, m - 2);
}
void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> v;
  if (k > n || (n % 2 == 1 && k % 2 == 0))
    cout << "NO"
         << "\n";
  else {
    if (n % 2 == k % 2) {
      for (int i = 1; i <= k - 1; i++) {
        v.push_back(1);
      }
      v.push_back(n - (k - 1));
      cout << "YES"
           << "\n";
      for (int i = 0; i < v.size(); i++) {
        cout << v[i] << " ";
      }
      cout << "\n";
    } else {
      if (n < (2 * k))
        cout << "NO"
             << "\n";
      else {
        for (int i = 1; i <= k - 1; i++) {
          v.push_back(2);
        }
        v.push_back(n - (2 * (k - 1)));
        cout << "YES"
             << "\n";
        for (int i = 0; i < v.size(); i++) {
          cout << v[i] << " ";
        }
        cout << "\n";
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
