Life on Mars? |
The Stardust Atmospheric and Surface Composition Spectrometer, Stardust's one-of-a-kind instrument, will measure the abundance of atmospheric gases around Mars and detect minerals in its surface materials. Once samples are taken, Stardust will transmit the findings to the Stardust Mission back to Earth. Nevertheless, scientists are afraid that upon the existence of Martians, Mars inhabitants, they will be clever enough to intercept messages, not only destroying them but also faking them.
The input consists of several test cases, one per line. Each test case contains a Stardust message: a non-empty sequence
S = S(0) S(1) ... S(n - 1)
For each case in the input, print one line. If the input message is valid, any idempotent permutation of the input message S
An Stardust message is a non-empty sequence
S = S(0) S(1) ... S(n - 1)
You have been assigned to the Stardust Mission. Your task is to write an efficient verifier for the messages received from the Stardust.
Input
The end of the input is indicated when the Stardust message is ``0''. Do not proccess this last line.
Output
Sample Input
2 0 1
2 1 1
3 2 2
2 2 2
1 2 2 1 1
2 4 1 3 0
2 4 2 3 0
2 4 6 3 0
5 8 1 9 4 0 7 11 2 6 10 3
5 2 1 2 4 0 7 11 2 6 2 3
1 2 1 2 1 0 7 11 2 6 2 1
1 2 1 2 1 0 7 7 2 6 2 1
1 2 1 2 1 0 7 7 2 6 12 1
0
Sample Output
0 1 2
1 1 2
Message hacked by the Martians!!!
2 2 2
1 1 2 1 2
0 1 2 3 4
0 2 2 3 4
Message hacked by the Martians!!!
0 1 2 3 4 5 6 7 8 9 10 11
0 1 2 3 4 5 6 7 2 2 2 11
0 1 2 1 1 1 6 7 2 2 2 11
0 1 2 1 1 1 6 7 2 2 2 7
Message hacked by the Martians!!!
Colombia'2008