[SOLUTION] k-LCM (hard version) solution codeforces

 

k-LCM (hard version) solution codeforces

SOLUTION

” COMING SOON “

[SOLUTION] k-LCM (hard version) solution codeforces


It is the hard version of the problem. The only difference is that in this version 3kn3≤k≤n. k-LCM (hard version) solution codeforces

You are given a positive integer nn. Find kk positive integers a1,a2,,aka1,a2,…,ak, such that:

  • a1+a2++ak=na1+a2+…+ak=n
  • LCM(a1,a2,,ak)n2LCM(a1,a2,…,ak)≤n2 k-LCM (hard version) solution codeforces

Here LCMLCM is the least common multiple of numbers a1,a2,,aka1,a2,…,ak.

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

Input

The first line contains a single integer tt (1t104)(1≤t≤104)  — the number of test cases.

The only line of each test case contains two integers nnkk (3n1093≤n≤1093kn3≤k≤n).

It is guaranteed that the sum of kk over all test cases does not exceed 105105.

For each test case print kk positive integers a1,a2,,aka1,a2,…,ak, for which all conditions are satisfied.

Example k-LCM (hard version) solution codeforces
input

Copy
2
6 4
9 5
output

Copy
1 2 2 1 
1 3 3 1 1 
Reactions