LEXBRAC - Bracket Sequence
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 a1a2 ... an is lexicografically smaller than the CBS b1b2 ... bn if and only if there exists an integer i, i <= n, so that aj=bj, for each j, 1 <= j < i and ai < bi.
Enumerate all CBS length 4 in lexicographical order: (()), ()(), (), (), [()], [], (), .
Your task is to find k-th CBS with length n in lexicographical order
Contains 2 integers n (2..250) and k (1..10^120)
Print the k-th CBS with length n in lexicographical order
Input: 4 3 Output: ()