Perhaps you have read that some problems are so classic that they barely need a statement. For this one, given a collection of coins with different values and a target amount , we ask you to indicate the way to add up to by using coins of the largest possible values. In particular, a way is better than another one if the former uses more coins of the largest value; in the event of a tie, if it uses more coins of the second largest value, etc.
Input consists of several cases. Each case begins with the number of coins between 1 and 100, followed by different integer numbers , where . Finally, we have an integer number .
For every case, print in non-increasing order the necessary coins to get , choosing the combination with coins of largest value in case of a tie. If there is no solution, print .
Input
8 1 2 5 10 25 50 100 200 481 3 1 4 5 5 6 428 19 521 67 84 101 75 6 428 19 521 67 84 101 749
Output
200,200,50,25,5,1 5 -1 521,19,19,19,19,19,19,19,19,19,19,19,19