#include <bits/stdc++.h>
const int INF = 1e+9, MAXN = 200005, HELL = 1e+9 + 7, MOD = 998244353;
const long long int INF64 = 1e+18;
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t, n, k;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    cin >> n >> k;
    if (n < k) {
      cout << "NO\n";
    } else {
      if ((n - k + 1) % 2 == 1) {
        cout << "YES\n";
        for (int j = 0; j < k - 1; ++j) {
          cout << "1 ";
        }
        cout << n - k + 1 << '\n';
      } else if (n >= 2 * k && (n - 2 * k + 2) % 2 == 0) {
        cout << "YES\n";
        for (int j = 0; j < k - 1; ++j) {
          cout << "2 ";
        }
        cout << n - 2 * k + 2 << '\n';
      } else {
        cout << "NO\n";
      }
    }
  }
  return 0;
}
