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