CF BUDDY
← Problems·

1567D · Expression Evaluation Error

2000 · constructive algorithms, greedy, implementation

Problem: On the board, Bob wrote nn positive integers in base 1010 with sum ss (i. e. in decimal numeral system). Alice sees the board, but accidentally interprets the numbers on the board as base-1111 integers and adds them up (in base 1111).

What numbers should Bob write on the board, so Alice's sum is as large as possible?

Input Format: The input consists of multiple test cases. The first line contains an integer tt (1t1001 \leq t \leq 100) — the number of test cases. The description of the test cases follows.

The only line of each test case contains two integers ss and nn (1s1091 \leq s \leq 10^9; 1nmin(100,s)1 \leq n \leq \min(100, s)) — the sum and amount of numbers on the board, respectively. Numbers ss and nn are given in decimal notation (base 1010).

Output Format: For each test case, output nn positive integers — the numbers Bob should write on the board, so Alice's sum is as large as possible. If there are multiple answers, print any of them.

Note: In the first test case, 7010+2710=971070_{10} + 27_{10} = 97_{10}, and Alice's sum is 7011+2711=9711=911+7=10610.70_{11} + 27_{11} = 97_{11} = 9 \cdot 11 + 7 = 106_{10}. (Here xbx_b represents the number xx in base bb.) It can be shown that it is impossible for Alice to get a larger sum than 10610106_{10}.

In the second test case, Bob can only write a single number on the board, so he must write 1717.

In the third test case, 310+410+10010+410=111103_{10} + 4_{10} + 100_{10} + 4_{10} = 111_{10}, and Alice's sum is 311+411+10011+411=11011=1112+111=13210.3_{11} + 4_{11} + 100_{11} + 4_{11} = 110_{11} = 1 \cdot 11^2 + 1 \cdot 11 = 132_{10}. It can be shown that it is impossible for Alice to get a larger sum than 13210132_{10}.

Sample Cases

Case 1

Input

6
97 2
17 1
111 4
100 2
10 9
999999 3

Output

70 27 
17 
3 4 100 4
10 90
1 1 2 1 1 1 1 1 1 
999900 90 9

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback