Graph Stem
InterviewTime limit1sMemory limit512 MB
Given a tree, repeatedly strip all leaves at once until two or fewer leaves remain, then output the surviving vertices in ascending order.
Problem
In a graph, a cycle is a path from a vertex back to the same vertex that repeats no edge and has length not equal to .
You are given a graph with no cycles.
Among the vertices of this graph, a vertex with exactly one incident edge is called an edge vertex.
Repeatedly delete all edge vertices at the same time. Once the graph becomes a straight line, the set of vertices that remain is called the stem of the graph. If the number of edge vertices is two or fewer, the graph is considered a straight line.

For the graph in the figure above, the edges connected to edge vertices are marked in red below.

Cutting the connections of the edge vertices attached to the red edges leaves the stem of the graph, connected in a straight line as in the figure below. Once the graph has become a straight line, no more edge vertices are deleted even if some remain.

Write a program that finds the vertices forming the stem of the graph.
Input
The first line of input gives the number of vertices in the initial graph.
The next lines give the numbers of the two vertices connected by each edge.
Output
On the first line of output, print the numbers of the vertices forming the stem of the graph in ascending order, separated by spaces.
Hint
The stem of the graph contains at least one vertex.