#C2169. Reconstruct the Packet Message

    ID: 45455 Type: Default 1000ms 256MiB

Reconstruct the Packet Message

Reconstruct the Packet Message

Given a list of packets, where each packet consists of a sequence number and a chunk of a message, your task is to reconstruct the original message by concatenating the chunks in ascending order of their sequence numbers. The sequence number (a positive integer) determines the order in which the message chunks should appear. The message chunks can include spaces and must be concatenated exactly as provided. Use appropriate sorting techniques to ensure the correct order.

Formally, if you are given packets ( (s_i, c_i) ) where ( s_i ) is the sequence number and ( c_i ) is the message chunk, the output should be ( c_{\pi(1)}c_{\pi(2)}...c_{\pi(n)} ) where ( \pi ) is the permutation that sorts the sequence numbers in increasing order.

inputFormat

The input is read from standard input (stdin).

The first line contains a single integer ( n ), representing the number of packets. Each of the following ( n ) lines contains a packet. Each packet line starts with an integer (the sequence number) followed by a space and then the corresponding message chunk. Note that the message chunk may include spaces.

outputFormat

Output the reconstructed message as a single string to standard output (stdout). The output should be exactly the concatenation of the message chunks in the order determined by their sequence numbers.## sample

1
1 Hello
Hello