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