In this problem, a function means a function that sends every integer from 1 to n to an integer from 1 to n. For example, when n=3, one possible function g is g(1)=1, g(2)=3, g(3)=1.
Define fj(x) as follows.
- f0(x)=x for every valid x.
- fj+1(x)=fj(f(x)) for every valid x and j.
The following notation is defined.
- G(f,w) is the set of the values fr(x) taken over every x with 1≤x≤n and every r with r≥w.
- S(f,w) is the size of G(f,w).
- Z(f) is the minimum of S(f,w) over all nonnegative integers w.
- A(y) is the set of the functions f with Z(f)=y.
Given n and k, write a program that computes the size of A(k) modulo 1,000,000,007.