URI Online Judge | 2872

TCP/IP Protocol

By Daniel Correia, IFSULDEMINAS BR Brazil

Timelimit: 1

The Transmission Control Protocol (TCP / IP) is a set of communication protocols in a network of computers for transmission of packets on the network. TCP is a "trusted" transport mechanism for providing a byte from the destination host (computer or device with network access) to the source host confirming that the packet was successfully received. The transfer is done by dividing the data into packets and sending one packet at a time. Another important feature of the TCP protocol is that since packets can be sent by different paths, packets can reach the target host out of order. Therefore, TCP orders the packets on the destination host so that the application is viewed on the monitor.

Assuming you are creating the TCP protocol, develop the algorithm that from the arrival of the sent packets, the same packets will appear in the destination host monitor, but in an orderly manner. Assume that bit "1" is sent to initiate the transfer and bit "0" to finalize the transfer of the packets.

Input

The input is composed of several test cases. The first line contains an integer "1" (without quotation marks) indicating the start of the transfer. The second and next lines contain the word "Package" concatenated with a 3-digit integer P (001 <= P <= 999), which identifies the packet. There are packages with equals identifiers! The reading of the test case packets is terminated with the last line of the test case containing an integer "0". The input ends with end of file.

Output

For each test case of your program inpuy, you must print all packets sent in an orderly fashion followed by a empty line.

Input Sample Output Sample

1
Package 005
Package 001
Package 002
Package 003
Package 004
0
1
Package 002
Package 001
Package 003
0
1
Package 002
Package 001
Package 005
Package 004
Package 001
Package 010
0

Package 001
Package 002
Package 003
Package 004
Package 005


Package 001
Package 002
Package 003


Package 001
Package 001
Package 002
Package 004
Package 005
Package 010