#P8235. [AGM 2022 资格赛] 括号

[AGM 2022 资格赛] 括号

Problem Description

You are given a tree with nn nodes. Node 11 is filled with a left parenthesis. You need to fill each of the remaining nodes with ( or ), so that the number of valid parenthesis paths on the tree is maximized. It is guaranteed that the answer is unique.

Input Format

The first line contains an integer nn.

The next n1n - 1 lines each contain two positive integers x,yx, y, indicating that there is an edge between xx and yy.

Output Format

Output a parenthesis string of length nn in one line.

3
1 2
1 3
())

Hint

Constraints

For 100%100\% of the testdata, it is guaranteed that 1n1051 \leq n \leq 10^5.

Notes

Translated from AGM 2022 Qualification Round G Parenthesis

Translated by ChatGPT 5