SP5093 PRETTY - Pretty Functions
Description
Let S = {1, 2, 3, ..., N}.
For a given positive integer K, the function f : S --> S is called "pretty" if, for every X in S, it holds that
f ( f ( f ( ... f ( X ) ... ) ) ) = X, where f is repeated exactly K times.
How many pretty functions are there, modulo M?
Input Format
Three natural numbers N, K and M. It holds that 1
Output Format
Number of pretty functions modulo M.