#abc305f. [abc305_f]Dungeon Explore
[abc305_f]Dungeon Explore
Problem Statement
This is an interactive problem (where your program and the judge program interact through Standard Input and Output).
There is a simple connected undirected graph with vertices and edges. The vertices are numbered with integers from to .
Initially, you are at vertex . Repeat moving to an adjacent vertex at most times to reach vertex .
Here, you do not initially know all edges of the graph, but you will be informed of the vertices adjacent to the vertex you are at.
Constraints
- The graph is simple and connected.
- All input values are integers.
Input and Output
First, receive the number of vertices and the number of edges in the graph from Standard Input:
Next, you get to repeat the operation described in the problem statement at most times against the judge.
At the beginning of each operation, the vertices adjacent to the vertex you are currently at are given from Standard Input in the following format:
Here, are integers between and such that .
Choose one of and print it to Standard Output in the following format:
After this operation, you will be at vertex .
If you perform more than operations or print invalid output, the judge will send -1
to Standard Input.
If the destination of a move is vertex , the judge will send OK
to Standard Input and terminate.
When receiving -1
or OK
, immediately terminate the program.
Notes
- In each output, insert a newline at the end and flush Standard Output. Otherwise, the verdict may be TLE