7311 - Pre-order   

Description

Giving a binary tree, please find the pre-order traversal of the tree

pre-order

Input

The first line of each case consists of two positive integers n (n<=100) and r denoting the number of nodes and the root of the tree. The next n line consists of three integers denoting the number of the node, left child, and right child (-1 denoting NULL).

Output

Print the pre-order traversal of the tree.

Sample Input  Download

Sample Output  Download

Tags




Discuss