It is the hard version of the problem. The only difference is that in this version 3 ≤ k ≤ n.

You are given a positive integer n. Find k positive integers a_1, a_2, …, a_k, such that:

  * a_1 + a_2 + … + a_k = n 
  * LCM(a_1, a_2, …, a_k) ≤ n/2 



Here LCM is the [least common multiple](https://en.wikipedia.org/wiki/Least_common_multiple) of numbers a_1, a_2, …, a_k.

We can show that for given constraints the answer always exists.

Input

The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases.

The only line of each test case contains two integers n, k (3 ≤ n ≤ 10^9, 3 ≤ k ≤ n).

It is guaranteed that the sum of k over all test cases does not exceed 10^5.

Output

For each test case print k positive integers a_1, a_2, …, a_k, for which all conditions are satisfied.

Example

Input


2
6 4
9 5


Output


1 2 2 1 
1 3 3 1 1 
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector <int> vi;
typedef vector <vi> vii;
typedef vector <string> vs;
typedef vector <ll> vll;

#define LSB(x) x&(-x)
#define endl "\n"
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f(a,b,c) for(ll (a)=(b);(a)<(c);++(a))
#define fi(a,b,c) for(ll (a)= (b);(a)<=(c);++(a))
#define fe(a,b) for(auto &(a) : (b))
#define fr(i,a,b) for(ll (i)=(a);(i)>(b);(i)--)
#define r(a,b) f(a,0,b)
#define SUM(x,s) for(ll i=0;i<(x).size();i++)(s)+=(x)[i];
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ALL(x) x.begin(),x.end()
#define SORT(x) sort(ALL(x))
#define TC(t) while(t--)
#define unS unordered_set
#define unM unordered_map
#define oS set
#define oM map
#define eb emplace_back
#define pq priority_queue
#define print(x) cout<<(x)<<endl



///////////////////// I/O shortcuts ////////////////////////////////
template <typename D>
istream& operator>> (istream &in , vector <D> &arr) {
	ll n = arr.size();
	r(i, n) {
		in >> arr[i];
	}
	return in;
}

template <typename D>
ostream& operator<< (ostream &in , vector <D> &arr) {
	for (auto x : arr) in << x << " ";
	in << endl;
	return in;
}
/////////////////////////////Power and Modulo///////////////////////////////////////

ll power(ll x, ll y)
{
	ll res = 1;

	while (y > 0)
	{
		if (y & 1)
			res = res * x;

		y = y >> 1;
		x = x * x;
	}
	return res;
}
int modulo = 1e9 + 7;
template <typename D>
D mod_add(D  &a, D b) {
	a += b;
	if (a > modulo) a -= modulo;
}
int sumUnderModulo(long long a, long long b)
{
	int M = 1000000007;

	return ((a % M) + (b % M)) % M;
}
////////////////////////////Global Variables////////////////////////////////
ll i, j, k, l, x, m, n, a, b, c, d, t = 1;
string s;
template<typename A, typename B> A max(A a, B b) {return (a > b) ? a : b;}
template<typename A, typename B> A min(A a, B b) {return (a < b) ? a : b;}
/////////// The Code Starts Here ///////////////////////////////////////


void solve(int tc) {
	cin >> n >> k;
	while (k != 3) {cout << "1 "; n--; k--;}
	if (n % k == 0) {
		r(i, k) cout << n / k << " ";
		cout << endl;
		return;
	}
	if (n % 2 == 1) {
		cout << 1 << " ";
		n--;
		cout << n / 2 << " " << n / 2 << endl;
	}
	else {
		if (n % 4 == 0) cout << n / 2 << " " << n / 4 << " " << n / 4 << endl;
		else cout << (n / 2 - 1) << " " << (n / 2 - 1) << " 2" << endl;
	}


}
///////////////////////////////////////////////////////////




int main() {
	quick;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	//cout << "it is starting \n";
	cin >> t;
	/*Debugging*/	auto st = clock();
	//cout << "It is Working Fine ";
	int k = 1;
	TC(t) solve(k++);
	st = clock() - st;
	//cout << "\nIt took ->" << (float)st / CLOCKS_PER_SEC << " seconds ";



}