#D1992. Permutation
Permutation
Permutation
Problem statement
Find the number of integer sequences that satisfy the following conditions.
- For any integer (), there exists () such that .
- ()
Constraint
- then
input
Input follows the following format. All given numbers are integers.
output
Divide the number of sequences that satisfy the condition by and output the remainder on one row (it is easy to show that the number of sequences that satisfy the condition is at most finite).
Examples
Input
3 1 1 1 1 3
Output
2
Input
4 2 1 1 2 3 3 2
Output
0
inputFormat
input
Input follows the following format. All given numbers are integers.
outputFormat
output
Divide the number of sequences that satisfy the condition by and output the remainder on one row (it is easy to show that the number of sequences that satisfy the condition is at most finite).
Examples
Input
3 1 1 1 1 3
Output
2
Input
4 2 1 1 2 3 3 2
Output
0
样例
3 1 1 1
1 3
2