Minhyuk built a function f:S→S from the set S={1,2,…,N} to itself. Write fk for applying f exactly k times in a row. The function Minhyuk built satisfies the following.
- fA1(1)=1
- fA2(2)=2
- …
- fAN(N)=N
Minhyuk wants to know how many different functions satisfy this. Given A1,A2,…,AN, write a program that counts them. Two functions g and h are different when there is at least one x with g(x)=h(x).