Let us define a regular brackets sequence in the following way:
-
Empty sequence is a regular sequence.
-
If “S” is a regular sequence, then “(S)” is a regular sequence.
-
If “A” and “B” are regular sequences, then “AB” is a regular sequence.
For example, all of the following sequences are regular brackets sequences: “()”, “(())”, “()()”, “()(())”.
And all of the following sequences are not: “(”, “)”, “)(”, “((()”.
Doc has $n$ pairs of brackets and he wants to know how many regular brackets sequences of length $2n$ can he construct that satisfy the x-th left bracket must not be matched before the y-th left bracket is matched($x < y$), tell him the answer modulo $10^9+ 7$.