SP2317 LEXBRAC - Bracket Sequence
Description
Correct Bracket Sequence (CBS) is a sequence that can be obtained through following rules:
1) An empty string is the CBS.
2) If $A$ is a CBS, then $B = (A)$ is also a CBS.
3) If $A$ is a CBS, then $B = [A]$ is also a CBS.
4) If $A$ and $B$ are CBS, then $C = AB$ is also a CBS.
Length of the CBS is the number of brackets in it, and this number is always even.
Assume that `(` < `)` < `[` < `]`.
CBS $a_1 a_2 \cdots a_n$ is lexicografically smaller than the CBS $b_1b_2 \cdots b_n$ if and only if there exists an integer $i , i \le n$ , so that $a_j=b_j$ , for each $j , 1 \le j < i$ and $a_i < b_i$.
Input Format
Contains 2 integers n (2..250) and k (1..10^120)
Output Format
Print the k-th CBS with length n in lexicographical order