#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int tt;
  cin >> tt;
  while (tt--) {
    int n, k;
    vector<int> v;
    cin >> n >> k;
    bool a = n % 2, b = k % 2, c = 1;
    if (a && !b) {
      c = 0;
    } else if (a && b || (!a && !b)) {
      if (n < k) {
        c = 0;
      } else {
        for (int i = 0; i < k - 1; i++) v.push_back(1);
        v.push_back(n - k + 1);
      }
    } else {
      if (n < k * 2) {
        c = 0;
      } else {
        for (int i = 0; i < k - 1; i++) v.push_back(2);
        v.push_back(n - (2 * k) + 2);
      }
    }
    if (c) {
      cout << "YES\n";
      for (int x : v) {
        cout << x << " ";
      }
      cout << "\n";
    } else {
      cout << "NO\n";
    }
  }
}
