There are people and messages in a chat room. The messages are numbered from oldest to newest.
Message was written by person , and exactly people have read message .
For each person , let be the index of the last message read by that person. If , the person has read no messages. If , the person has read every message and has not read messages .
A person is considered to have read every message up to each message they wrote. Therefore, must hold for every .
A sequence is valid if all of the following conditions hold.
- ().
- ().
- Exactly people satisfy ().
The input sequence satisfies . It is also guaranteed that at least one valid sequence exists.
Find the number of valid sequences modulo .
Input
The input is given from Standard Input in the following format:
Output
Print the number of valid sequences modulo .
Constraints
- .
- .
- ().
- ().
- ().
- At least one valid sequence exists.