#C14948. Generate Parentheses

    ID: 44653 Type: Default 1000ms 256MiB

Generate Parentheses

Generate Parentheses

Given a single integer \(n\), generate all valid combinations of parentheses using exactly \(n\) pairs. A valid combination is defined as one that can be correctly matched as open and close parentheses. The combinations should be returned in lexicographical order.

For example, for \(n = 3\), the valid combinations are:

((()))
(()())
(())()
()(())
()()()

If \(n = 0\), output nothing.

inputFormat

The input consists of a single integer \(n\) (where \(0 \le n \le 10\)), representing the number of pairs of parentheses.

outputFormat

Output all valid parenthetical expressions in lexicographical order, each on a new line. If there are no valid expressions (i.e. when \(n = 0\)), output nothing.

## sample
0