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 if all of the following conditions hold.
The input sequence satisfies . It is also guaranteed that at least one valid sequence exists.
Find the number of valid sequences modulo .
The input is given from Standard Input in the following format:
Print the number of valid sequences modulo .
| 3 | 22 | . |
| 4 | 25 | No additional constraints. |