#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int n, k;
    cin >> n;
    cin >> k;
    if (n % 2 != 0) {
      if ((k - 1) % 2 == 0 && (n - k + 1) % 2 != 0 && (n - k + 1) > 0) {
        cout << "YES" << endl;
        for (int i = 0; i < (k - 1); i++) {
          n--;
          cout << 1 << " ";
        }
        cout << n << endl;
      } else
        cout << "NO" << endl;
    } else {
      if ((k - 1) % 2 == 0 && (n - (2 * k) + 2) % 2 == 0 &&
          (n - (2 * k) + 2) > 0) {
        cout << "YES" << endl;
        for (int i = 0; i < (k - 1); i++) {
          n = n - 2;
          cout << 2 << " ";
        }
        cout << n << endl;
      } else {
        if ((k - 1) % 2 != 0 && (n - k + 1) % 2 != 0 && (n - k + 1) > 0) {
          cout << "YES" << endl;
          for (int i = 0; i < (k - 1); i++) {
            n = n - 1;
            cout << 1 << " ";
          }
          cout << n << endl;
        } else
          cout << "NO" << endl;
      }
    }
  }
  return 0;
}
