#include <bits/stdc++.h>
bool isT = true;
void solv(int curt);
int main() {
  std::ios::sync_with_stdio(0);
  std::cin.tie(0);
  if (isT) {
    int t;
    std::cin >> t;
    for (int i = 1; i <= t; i++) {
      solv(i);
    }
    return 0;
  }
  solv(0);
  return 0;
}
void solv(int curt) {
  long long n, m;
  std::cin >> n >> m;
  if ((n - m + 1LL) % 2LL == 1LL && (n - m + 1) > 0LL) {
    std::cout << "YES\n";
    std::cout << n - m + 1LL << " ";
    for (long long i = 0LL; i < m - 1LL; i++) {
      std::cout << "1"
                << " \n"[i == m - 2LL];
    }
    return;
  }
  if ((n - 2 * (m - 1)) % 2LL == 0LL && n - 2 * (m - 1) > 0LL) {
    std::cout << "YES\n";
    std::cout << n - 2 * (m - 1) << " ";
    for (long long i = 0LL; i < m - 1LL; i++) {
      std::cout << "2"
                << " \n"[i == m - 2LL];
    }
    return;
  }
  std::cout << "NO\n";
}
