#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  long long temp = 0;
  long long a = 0, b = 0, p = 1, q = 0;
  long long x = 0, y = 0, z = 0;
  long long n = 0, m = 0;
  long long sum = 0, res = 0;
  long long mid = 0, l = 0, r = 0;
  long long maxi = 0, maxelement = 0, mini = 0;
  long long count = 0;
  long long k = 0;
  int flag = 0;
  string s;
  string ans;
  vector<long long>::iterator itr;
  vector<long long> vec2;
  vector<long long> vec;
  unordered_map<long long, long long> mp;
  vector<string> vecs;
  set<long long> st;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    if (n < k) {
      cout << "NO" << endl;
      continue;
    }
    if ((n - (k - 1)) % 2 == 1) {
      cout << "YES" << endl;
      x = k - 1;
      while (x--) cout << 1 << " ";
      cout << n - (k - 1) << endl;
    } else if ((n - (k - 1) * 2) % 2 == 0 && n - (k - 1) * 2 > 0) {
      cout << "YES" << endl;
      x = k - 1;
      while (x--) cout << 2 << " ";
      cout << n - (k - 1) * 2 << endl;
    } else
      cout << "NO" << endl;
  }
  return 0;
}
