You have just lost an integer array
aaa of length
nnn. You only remember that the array satisfies the following conditions:
-
1≤ai≤m1 \leq a_{i} \leq m1≤ai≤m.
-
For some pairs of (u,v)(u,v)(u,v), au≠va_{u} \neq vau=v.
-
For some pairs of (u,v)(u,v)(u,v), numu≠vnum_{u} \neq vnumu=v, where numunum_{u}numu represents the number of occurrences of number uuu. For example, if a={1,3,3,2,4}a=\{1,3,3,2,4\}a={1,3,3,2,4}, then num3=2num_{3} = 2num3=2, num1=1num_{1} = 1num1=1, num2=1num_{2} = 1num2=1, num4=1num_{4} = 1num4=1.
Also, you remember an extra information: there is an array
BBB of length
mmm, such that after sorting the array
[num1,num2…numm][num_{1},num_{2} \dots num_{m}][num1,num2…numm] in non-decreasing order, it will become
BBB.
Please calculate the number of possible arrays under these constraints. Since the answer might be huge, output the answer modulo
109+710^9 + 7109+7.