You are given a simple directed graph with vertices numbered . The graph is connected when all edge directions are ignored.
Choose some edges of to form a rooted spanning tree satisfying all of the following conditions.
- Every non-root vertex has one parent , and the directed edge exists in .
- For the root , .
- The selected edges form a rooted spanning tree directed from parents to children.
- For every directed edge that is not selected as a tree edge, is a proper ancestor of in the tree.
A proper ancestor of a vertex is an ancestor other than the vertex itself.
The following figure shows one valid example. Red edges are tree edges directed from parents to children. Blue edges are non-tree edges directed from descendants to ancestors.
Find a parent sequence satisfying the conditions, or report that none exists.
Input
The input is given in the following format:
The -th edge is directed from to .
Output
If a valid tree exists, print separated by spaces on one line. The parent of the root must be printed as .
If there are multiple solutions, print any of them.
If no valid tree exists, print -1 on one line.
When , the single value -1 is a valid parent sequence.
Constraints
- .
- .
- ().
- ().
- ().
- The graph is connected when all edge directions are ignored.
Subtasks
Samples
Choose vertex as the root and the red edges in the figure as tree edges. Every blue edge points from a descendant to an ancestor.
No rooted spanning tree satisfies all conditions.