There are many boxes. In each box; there are treasures of different values. Make a list of these boxes, in which they are sorted by the total value of treasures in them from large to small. If two boxes have the same total value, the one appearing earlier in the input data should be output first. And in each box, list the treasures values from small to large.
There are multiple test cases. Each case begins with an integer N (1 <= N <= 104) which represents the number of boxes. In the next N lines, each line contains a sequence of positive integers, representing the value of the treasures. There are at most 103 treasures in one box. Each line is terminated by 0. The input is terminated by N = 0 in a single line.
For each test case, output the sorted boxes in N lines. In each line, output a sequence of sorted integers, representing the values of treasures. Use a blank line to separate two test cases.