There are two printers, A and B. Each printer contains cards. In each printer, the numbers from to appear exactly once.
Let be the cards in printer A from front to back, and let be the cards in printer B from front to back.
You perform exactly operations to print all cards. In one operation, choose a printer that still has at least one card, print its front card, and remove that card.
The first operation causes no switch. Starting from the second operation, the number of switches increases by whenever the chosen printer differs from the printer used in the previous operation.
After all operations, the printed numbers form an output sequence in order. The same output sequence may be produced by more than one sequence of operations.
Count the distinct output sequences that can be produced by an operation sequence using at most switches. If several operation sequences produce the same output sequence, count that output sequence once as long as at least one of them uses at most switches.
Print the answer modulo .
The input is given in the following format.
Print the number of distinct output sequences satisfying the condition, modulo .
Printing all cards requires using both printers and hence at least one switch. Since , no output sequence is possible.
Using A then B, or B then A, requires one switch. Both methods produce , so this sequence is counted once.
The four possible output sequences are , , , and . They can be produced using printers in the orders AABB, ABBA, BAAB, and BBAA, respectively, with switches.
Even if another method producing the same sequence uses more than switches, the sequence is counted once whenever at least one method satisfies the limit.