MOD = 10**9 + 7 # Stirling numbers of the first kind S(x, m) stirling = [ [], [0, 1], [0, 1, 1], [0, 2, 3, 1], [0, 6, 11, 6, 1], [0, 24, 50, 35, 10, 1], [0, 120, 274, 225, 85, 15, 1], [0, 720, 1764, 1624, 735, 175, 21, 1], [0, 5040, 13068, 13132, 6769, 1960, 322, 28, 1], ] # Partition numbers p(x, m) for x from 0 to 8 partitions = [ [], [0, 1], [0, 1, 1], [0, 1, 1, 1], [0, 1, 2, 1, 1], [0, 1, 2, 2, 1, 1], [0, 1, 3, 3, 2, 1, 1], [0, 1, 3, 4, 3, 2, 1, 1], [0, 1, 4, 5, 5, 3, 2, 1, 1], ] x = int(input()) result = 1 for m in range(1, x + 1): p = partitions[x][m] if p == 0: continue sign = (-1) ** (x - m) s = stirling[x][m] base = sign * s base_mod = base % MOD term = pow(base_mod, p, MOD) result = (result * term) % MOD print(result)