You have been a treasure hunter for a long time. Disarming traps, slipping past the locals, and walking out with the goods and your skin intact is routine work by now. What makes you sweat is the argument that follows every expedition, when the crew has to split the loot. You have worked with all sorts of people, and nobody ever agrees on what a single piece of treasure is really worth. You need a way to split the haul as fairly as possible.
The input holds a series of data sets, at least 1 and at most 100 of them. No blank line separates one data set from the next.
A single data set has five parts.
START.END.Print one output set per data set, with exactly one blank line between consecutive output sets.
An output set has one line per hunter, in the same order as the input. Each line lists the treasure numbers that hunter receives in ascending order, then the total value of those treasures as that hunter prices them. All values on a line are separated by spaces. A hunter who receives no treasure gets a line holding only the total 0.
Divide the treasures as fairly as possible. Every treasure goes to exactly one hunter, and no treasure is left over. The fairest division is the one that minimizes the difference between the largest and the smallest of the per hunter totals, so the hunter who feels they got the most and the hunter who feels they got the least end up as close together as possible.
No input has more than one fair division.