Unrank pairs of parentheses

In general, there are many ways to place nn pairs of parentheses correctly. For instance, these are just a few of the 42 ways for n=5n = 5:

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

The following rules inductively define all the correct strings made up with parentheses:

Let |s|\vert s \vert denote the length of a string ss. We can define as follows a total order among the correct strings with parentheses:

Can you write a program to compute the ii-th correct string with nn pairs of parentheses?

Input

Input consists of several cases, each one with two numbers ii and nn. Assume 0n300 \le n \le 30 and that ii is between 1 and the number of correct strings with nn pairs of parentheses.

Output

For every case, print the ii-th correct string with nn pairs of parentheses.

Problem information

Author: Salvador Roura

Generation: 2026-01-25T10:09:21.876Z

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