#include <bits/stdc++.h>
using namespace std;
long long t, n, m, x, mx = -1e18, mn = 1e18, ans, sum, con;
long long a[2020202];
string s;
map<long long, long long> mp;
vector<long long> v;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL), cout.tie(NULL);
  cin >> t;
  while (t--) {
    long long k;
    cin >> n >> k;
    if (k == 1) {
      cout << "YES\n";
      cout << n << "\n";
      continue;
    }
    if (k > n || n - k == 1) {
      cout << "NO\n";
      continue;
    }
    if (n % 2 == 0) {
      if (k % 2 == 0) {
        cout << "YES\n";
        for (int i = 1; i < k; i++) cout << 1 << " ";
        cout << (n - (k - 1));
        cout << "\n";
      } else {
        if ((k * 2) > n) {
          cout << "NO\n";
          continue;
        } else {
          cout << "YES\n";
          for (int i = 1; i < k; i++) cout << 2 << " ";
          cout << (n - ((k - 1) * 2)) << "\n";
        }
      }
    } else {
      if (k % 2 == 0) {
        cout << "NO\n";
        continue;
      }
      cout << "YES\n";
      for (int i = 1; i < k; i++) cout << 1 << " ";
      cout << (n - (k - 1)) << "\n";
    }
  }
}
