A treasure is locked into a room of a well-guarded dungeon. At the door of the room, there is a magic scale and a set of N weights. The scale has an associated unknown target total weight W. We have the following properties:
One way to guarantee opening the door and reaching the coveted treasure is therefore to try all subsets of the N weights in order of increasing total weight. However, multiple subsets might have the same total weight, so a better strategy is to try one subset for each given total weight.
Help our adventurer by enumerating the first K possible total weights in increasing order, together with one corresponding subset of weights for each total weight.
K lines representing the first K possible total weights in increasing order, together with the corresponding weights. The format of each of the K lines is:
total_weight: weight_1 weight_2 ... weight_p
where weight_1 weight_2 ... weight_p are p space-separated weights that sum to total_weight (if there are multiple options, any will be accepted).
It is guaranteed that it will be possible to find at least K different weight sums given the input data.