There are rooms in a row and impostors such that initially (at second ), the impostor is in room . From room , there is a directed vent to room , such that no two vents have the same destination (forming a permutation of integers from to ). The impostors move in the following way: the impostor who was in room at second will move ("vent") to room at second .
After seconds you can track where each impostor is: the is in room . Now, you wonder: how many vent configurations (permutations ) can lead to this? Since the answer can be very large, output it modulo . Note that your tracking device might be faulty, so the answer can be .
Task
Write a program that, knowing and the position of each impostor after seconds, calculates how many possible vent permutations exist.
Input Data
The first line of input contains two integers and .
The second line contains integers (), representing the positions of the impostors after seconds. It is guaranteed that forms a permutation of integers from to .
Output Data
The output consists of one integer: the number (modulo ) of permutations , such that after seconds, impostor would be in room for each .
Restrictions
- .
| # | Points | Restrictions | 
|---|---|---|
| 1 | 11 | and | 
| 2 | 11 | |
| 3 | 28 | |
| 4 | 16 | |
| 5 | 20 | |
| 6 | 14 | No additional restrictions | 
Example 1
stdin
3 3
1 2 3
stdout
3
The valid permutations are and .
Example 2
stdin
5 2
3 1 5 4 2
stdout
0