#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int test;
  cin >> test;
  while (test--) {
    int sum = 0;
    int a, b;
    cin >> a >> b;
    if ((a % 2 == 1 && b % 2 == 0) || (a % 2 == 0 && b % 2 == 1 && b > a / 2) ||
        b > a) {
      cout << "NO";
    } else {
      if (a % 2 == 0 && b <= a / 2) {
        cout << "yes" << endl;
        for (int i = 1; i < b; i++) {
          cout << "2"
               << " ";
          sum += 2;
        }
        cout << a - sum;
      } else if (a % 2 == 0 && b % 2 == 0 && b > a / 2) {
        cout << "yes" << endl;
        for (int i = 1; i < b; i++) {
          cout << "1"
               << " ";
          sum += 1;
        }
        cout << a - sum;
      } else {
        cout << "yes" << endl;
        for (int i = 1; i < b; i++) {
          cout << "1"
               << " ";
          sum += 1;
        }
        cout << a - sum;
      }
    }
    cout << endl;
  }
}
