CF1346A.Color Revolution

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

Color Revolution

Hmm, how long has it been since the last color revolution? 5 years?! It's totally the time to make a new one!

So the general idea is the following. Division 11 should have n1n_1 participants. Division 22 should have n2n_2 and be exactly kk times bigger than division 11 (n2=kn1n_2 = k \cdot n_1). Division 33 should have n3=kn2n_3 = k \cdot n_2 participants. Finally, division 44 should have n4=kn3n_4 = k \cdot n_3 participants.

There are nn participants on Codeforces in total. So n1+n2+n3+n4n_1 + n_2 + n_3 + n_4 should be exactly equal to nn.

You know the values of nn and kk. You also know that nn and kk are chosen in such a way that there exist values n1,n2,n3n_1, n_2, n_3 and n4n_4 such that all the conditions are satisfied.

What will be the number of participants in each division (n1,n2,n3n_1, n_2, n_3 and n4n_4) after the revolution?

Input

The first line contains a single integer tt (1t10001 \le t \le 1000) — the number of testcases.

Each of the next tt lines contains two integers nn and kk (4n1094 \le n \le 10^9; 1k5001 \le k \le 500) — the total number of participants on Codeforces and the size multiplier for the corresponding testcase. In each testcase, nn and kk are chosen in such a way that the answer exists.

Output

For each testcase print four integers n1,n2,n3n_1, n_2, n_3 and n4n_4 such that n2=kn1n_2 = k \cdot n_1, n3=kn2n_3 = k \cdot n_2, n4=kn3n_4 = k \cdot n_3 and n1+n2+n3+n4=nn_1 + n_2 + n_3 + n_4 = n.

Samples

4
40 3
1200 7
320802005 400
4 1
1 3 9 27
3 21 147 1029
5 2000 800000 320000000
1 1 1 1

在线编程 IDE

建议全屏模式获得最佳体验