Олимпиадный тренинг

Задача 44774. tree branches


Задача

Темы: Деревья

For the resulting tree, print a list of all vertices that have only one child, in ascending order.


Input

Enter a sequence of integers ending in zero. Build a tree based on it.


Output

Display the list of required vertices.

 

Examples
# Input Output
1
7 3 2 1 9 5 4 6 8 0
2
9