Theater Entry/Exit Sequences
A theater has a line of people wanting to watch a show. Each person must enter the theater, then later exit it. The entry/exit log records a sequence of E (enter) and X (exit) events.
A valid entry/exit sequence must satisfy two rules:
- At any point while reading left to right, the number of exits never exceeds the number of entries (you can't exit if nobody is inside).
- The total number of entries equals the total number of exits.
Given that n people enter and n people exit, count the number of distinct valid entry/exit sequences.
Input
The first line contains an integer n (1 ≤ n ≤ 35).
Output
Print the count of valid entry/exit sequences of length 2n with n entries and n exits, modulo 10^9 + 7.
Notes
A valid sequence of length 2 (n=1) is just EX (one person enters, then exits). There is 1 such sequence.
For n=2, valid sequences are EEXX, EXEX. There are 2 sequences (sequences where someone exits before both have entered, like XEEX or EXXE, are invalid).