#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t, n, k;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    if (k % 2) {
      if (n % 2) {
        n -= k - 1;
        if (n > 0) {
          cout << "YES\n";
          for (int i = (0); i < (k - 1); ++i) {
            cout << "1 ";
          }
          cout << n << "\n";
        } else {
          cout << "NO\n";
        }
      } else {
        n -= (k - 1) * 2;
        if (n > 0) {
          cout << "YES\n";
          for (int i = (0); i < (k - 1); ++i) {
            cout << "2 ";
          }
          cout << n << "\n";
        } else {
          cout << "NO\n";
        }
      }
    } else {
      if (n % 2) {
        cout << "NO\n";
      } else {
        n -= (k - 1);
        if (n > 0) {
          cout << "YES\n";
          for (int i = (0); i < (k - 1); ++i) {
            cout << "1 ";
          }
          cout << n << "\n";
        } else {
          cout << "NO\n";
        }
      }
    }
  }
  return 0;
}
