Parentheses Order (Small)

Print the k-th valid parentheses string of n pairs in lexicographic order for each test case, or report that it does not exist.

Medium5Dynamic programmingCombinatoricsInterviewNo attempts yetTime limit5sMemory limit512 MB

Problem

A parentheses string of length 2n2n consists of nn opening brackets ( and nn closing brackets ).

A valid parentheses string is defined like this:

A string you can turn into the empty string by repeatedly erasing an adjacent () pair.

For example, (()) is valid. Erase the pair at positions 2 and 3 to get (), then erase that pair to get the empty string. )()( is not valid. Erasing the pair at positions 2 and 3 leaves )(, and nothing more can be erased.

Collect every valid parentheses string with nn opening and nn closing brackets, sort them in lexicographic order, and find the kk-th one. In this comparison ( comes before ).

For n=3n = 3 the valid parentheses strings in lexicographic order are:

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

Input

The first line has the number of test cases TT. Each of the next TT lines has two integers nn and kk separated by a space.

Output

For each test case print one line in the form Case #x: y. Here xx is the test case number starting from 1, and yy is the string that comes kk-th in lexicographic order among the valid parentheses strings with nn opening and nn closing brackets. If fewer than kk such strings exist, print Doesn't Exist! in place of yy.

Constraints

  • 1T1001 \le T \le 100
  • 1n101 \le n \le 10
  • 1k1000001 \le k \le 100000