#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define vll vector<ll>
#define vvl vector<vector<ll>>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define uset unordered_set
#define pbk push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define sortrev(x) sort(all(x), greater<ll>())
#define op(x) cout<<x<<endl
#define opl(x) cout<<x<<" "
#define show(x) cout <<(#x)<<" : "<<x<<endl
#define speedhack ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define YESNO(cond) cout<<(cond?"YES":"NO")<<endl
#define MOD 1000000007
#define MAX 200005

void TLEsol();
int main(){
  speedhack;
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  int t=1;
  cin>>t;
  while(t--) TLEsol();
    return 0;
}

void TLEsol(){
  ll n,k;
  cin>>n>>k;
  n -= (k-3);
  if(n%4==0){
    opl(n/4);opl(n/4);opl(n/2);
  }else if(n%4==1 || n%4 == 3){
    opl("1");opl(n/2);opl(n/2);
  }else if(n%4==2){
    opl("2");opl((n/2)-1);opl((n/2)-1);
  }
  k-=3;
  while(k--){
    opl("1");
  }
  op("");
}
