Surjective functions count

Write codeHard30 minCitadel style

Your task

Count the number of surjective (onto) functions from a set of size n to a set of size m, i.e. functions that hit every one of the m targets at least once. Return the count modulo 1_000_000_007. If m > n the answer is 0; n,m can be up to a few thousand.

Examples

count_surjections(n: int, m: int) -> int
Example 1
Inputcount_surjections(3, 2)
Output6