Time limit
2s
Memory limit
128 MB
Given a binary tree, print the preorder, inorder, and postorder traversal results.
In preorder traversal, visit the current node first, then the left subtree, then the right subtree. In inorder traversal, visit the left subtree, then the current node, then the right subtree. In postorder traversal, visit the left subtree, then the right subtree, then the current node.
The first line contains the number of nodes N (1 <= N <= 26). Each of the next N lines contains a node, its left child, and its right child.
Node names are uppercase letters assigned in order starting from A, and A is always the root. If a child does not exist, it is written as ..
Print three lines. The first line must contain the preorder traversal, the second line the inorder traversal, and the third line the postorder traversal.
Each line should contain the visited node names as a contiguous string with no spaces.