#include <bits/stdc++.h>
const long long maxn = 1e5 + 7;
const long long inf = 1e18;
using namespace std;
long long t;
long long n, k;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> t;
  for (int ii = 0; ii < t; ii++) {
    cin >> n >> k;
    if (k > n)
      cout << "no"
           << "\n";
    else if (n % 2 != 0 && k % 2 == 0)
      cout << "no"
           << "\n";
    else if (n % 2 == 0 & k % 2 != 0 && n < 2 * k)
      cout << "no" << endl;
    else {
      cout << "yes"
           << "\n";
      if (n % 2 == 0 && k % 2 == 1) {
        for (int i = 0; i < k - 1; i++) {
          cout << 2 << " ";
          n -= 2;
        }
        cout << n << "\n";
      } else if (n % 2 == 0 && k % 2 == 0) {
        for (int i = 0; i < k - 1; i++) {
          cout << 1 << " ";
          n -= 1;
        }
        cout << n << "\n";
      } else if (n % 2 == 1) {
        for (int i = 0; i < k - 1; i++) {
          cout << 1 << " ";
          n -= 1;
        }
        cout << n << "\n";
      }
    }
  }
}
