Trees and parentheses

Write a program that reads the shape of various general trees and prints
the parenthesis associated to each tree, as it is shown at the instance.

Input

Input starts with m, the number of trees that must be treated. The
description of the m trees follow as is explained at the exercise REREG,
with two exceptions: The values are not given, because the content of
the nodes here is not important. The number of nodes is neither given,
because you do not need to store the trees in any vector to solve this
exercise.

Output

Your program must print a line for each tree of the input, with its
associated parentheses.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T11:31:15.150Z

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