In the event of technical difficulties with Szkopuł, please contact us via email at [email protected].
If you would like to talk about tasks, solutions or technical problems, please visit our Discord servers. They are moderated by the community, but members of the support team are also active there.
King Informaticus, a ruler of Byteland has a lot to worry about. Secret service informed him that a cruel King Hacker is about to attack his kingdom. Moreover, secret agents of Hacker have been already sent to one of the cities in Byteland in order to hinder preparations for defense. Informaticus decided to warn his subjects against an oncoming danger.
Citizens of Byteland live only in cities. Cities have numbers from to , where . The capital city has number . There is a well developed system of roads in Byteland, all of them are two-way roads. Any two cities have no more than one direct connection, but for any two different cities and one can get from to and then return from to without going again through any of the cities on the way from to .
King Informaticus decided to send two messengers to warn his subjects. Each messenger moves on the roads of Byteland and may visit one city a couple of times. But the order in which they arrive to certain cities for the first time should be in accord with King's plan.
The plan is a series of integers from the interval , where . On the way from the city to the city an agent can go through any finite number of cities, but only these that he had visited before. Unfortunately, spies of King Hacker sat a trap to catch the messengers and imprison any of them who comes to the occupied city. Thus the plan of routes of two messengers should be such that each city is visited by at leas one messenger, before they will be captured by agents hidden in one of the cities different than the capital.
Write a program that:
In the first line of the standard input one integer is written. This is the number of all the cities in Byteland. In the second line one integer is written. This is the number of all the direct road connections. In each of the following lines there is written the description of one direct road connection, it consists of two different integers from the interval separated by a single space. Each connection appears only once in the text file.
In the first line of the standard output there should be written the plan of the route of the first messenger as a series of different integers from the interval , separated by a single space. In the second line there should be written, in the same way, the plan of the route of the second agent.
For the input data:
5 6 1 2 2 3 3 4 4 1 4 5 5 2
the correct result is:
1 2 3 5 4 1 4 5 3 2
Task author: Krzysztof Diks.