Write a program that reads the description of a general tree of natural numbers and prints its postorder traversal.

In this exercise as well as in the rest of exercises of this section,
unless the contrary is said the description of a general tree consists of the number of nodes *n* followed by the
pre-order traversal, in which the value of each node
is followed by its number of children.
This traversal has 2*n* elements.

(To see an instance with the tree corresponding to the input-output instance, consult the pdf or ps version of this wording.)

To solve this exercixe as well as most of the exercises of this section, you will need to store the tree in a vector. Do it using this code (slightly modified if it is necessary):

Each position of the vector stores the value of a node, and the vector with the positions of all its children from the left to the right. The position of the tree root is always 0.

**Input**

Input consists of the description of a general tree of natural numbers.

**Output**

Your program must print a line with the postorder traversal of the general tree. Each element must be preceded by a space.

Public test cases

**Input**

12 7 3 8 0 4 2 3 1 0 1 6 0 5 0 2 4 9 0 1 0 8 0 5 0

**Output**

8 6 0 3 5 4 9 1 8 5 2 7

Information

- Author
- Salvador Roura
- Language
- English
- Translator
- Carlos Molina
- Original language
- Catalan
- Other languages
- Catalan
- Official solutions
- C++
- User solutions
- C++