#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
int n, k;
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    cin >> n >> k;
    if (n < k) {
      cout << "NO"
           << "\n";
      continue;
    }
    int a = n / k, b = n % k;
    if (b == 0) {
      cout << "YES"
           << "\n";
      for (int i = 0; i < k; ++i) cout << a << " ";
      cout << "\n";
    } else {
      if ((a + b) % 2 == a % 2) {
        cout << "YES"
             << "\n";
        for (int i = 0; i < k - 1; ++i) cout << a << " ";
        cout << a + b << " \n";
      } else {
        a--;
        b += k;
        if (a && (a + b) % 2 == a % 2) {
          cout << "YES"
               << "\n";
          for (int i = 0; i < k - 1; ++i) cout << a << " ";
          cout << a + b << " \n";
        } else {
          cout << "NO"
               << "\n";
        }
      }
    }
  }
  return 0;
}
