#abc267g. [abc267_g]Increasing K Times
[abc267_g]Increasing K Times
Problem Statement
You are given an integer sequence of length .
Find the number, modulo , of permutations of such that:
- there exist exactly integers between and (inclusive) such that .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
4 2
1 1 2 2
Sample Output 1
4
Four permutations satisfy the condition: $P = (1, 3, 2, 4), (1, 4, 2, 3), (2, 3, 1, 4), (2, 4, 1, 3)$.
Sample Input 2
10 3
3 1 4 1 5 9 2 6 5 3
Sample Output 2
697112