Consider a restaurant with an infinite number of tables, which are numbered as 1, 2, 3, ..., and so on. Each table has 5 seats. When a customer enters the restaurant, he gets a ticket showing a positive integer as his lucky number. He then goes through each table to find a seat. He can take the seat as long as the following two conditions hold: (1) The table is not full yet. (2) His lucky number is greater than the lucky number of anyone at that table. For example, if the lucky numbers of the customers are issued as follows:
1 7 5 6 8 9 2 10 11 3 12 4 13 7 7
The final seating would be
Table No. 1: 1 7 8 9 10
Table No. 2: 5 6 11 12 13
Table No. 3: 2 3 4 7
Table No. 4: 7
The input contains a sequence of positive integers as the lucky numbers, except the last one, which is -1, indicating the end of the input.
The output contains several lines. Each line lists the largest lucky number of the table. Each line should be ended with a newline character '\n'.