Surfing a tree

Write a program that reads a non empty binary tree of words, places at the root of the tree, and then moves in the tree followings the orders that is given.

Input

Input starts with the description of a non empty tree as is explained at the exercise REREC. Afterwards, a sequence of words that can be "up", "left" or "right" comes.

Output

Your program must print the content of the initial position, and of the position after each step. The order that would cause to go out of the tree must be ignored, but writing the content of the position.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T11:20:28.477Z

© Jutge.org, 2006–2026.
https://jutge.org