#TENKA12018F. Circular
Circular
Score : points
Problem Statement
You are given a sequence of integers: .
Find the number of permutations of that can be changed to by performing the following operation some number of times (possibly zero), modulo :
- For each , let , where . Replace the sequence with the sequence .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the number of the sequences that satisfy the condition, modulo .
and satisfy the condition.