#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long N = 2e5;
const long long inf = 1e18;
long long add(long long a, long long b) {
  long long res = (a + b) % mod;
  return (res < 0) ? res + mod : res;
}
long long mul(long long a, long long b) {
  long long res = (a * 1LL * b) % mod;
  return (res < 0) ? res + mod : res;
}
bool compare(long long x, long long y) { return x > y; }
struct Compare {
  bool operator()(pair<long long, long long> A, pair<long long, long long> B) {
    return A.first > B.first;
  }
};
void solve() {
  long long t;
  cin >> t;
  while (t--) {
    long long n, k, y;
    bool flag;
    cin >> n >> k;
    flag = true;
    vector<long long> ans;
    if (n % 2 || n < 2 * k) {
      n -= k;
      flag = (n >= 0 && n % 2 == 0);
      if (flag) {
        for (long long i = 0; i < k - 1; i++) {
          ans.push_back(1);
        }
        ans.push_back(n + 1);
      }
    } else {
      for (long long i = 0; i < k - 1; i++) {
        ans.push_back(2);
      }
      ans.push_back(n - 2 * k + 2);
    }
    if (flag) {
      cout << "YES"
           << "\n";
      for (auto y : ans) cout << y << " ";
    } else {
      cout << "NO";
    }
    cout << "\n";
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
