import sys from collections import Counter MOD = 10**9 + 7 def generate_partitions(n): partitions = [] def helper(n, max_part, current): if n == 0: partitions.append(current.copy()) return for i in range(min(max_part, n), 0, -1): current.append(i) helper(n - i, i, current) current.pop() helper(n, n, []) return partitions x = int(sys.stdin.readline()) partitions = generate_partitions(x) p = len(partitions) # Precompute factorials up to x fact = [1] * (x + 1) for i in range(1, x + 1): fact[i] = fact[i-1] * i % MOD x_fact = fact[x] x_fact_p = pow(x_fact, p, MOD) product_f = 1 for part in partitions: k = len(part) counts = Counter(part) sign = 1 if (x - k) % 2 == 0 else MOD - 1 numerator = (sign * fact[k-1]) % MOD denominator = 1 for m, cnt in counts.items(): m_fact = fact[m] term = pow(m_fact, cnt, MOD) term = term * fact[cnt] % MOD denominator = (denominator * term) % MOD inv_denominator = pow(denominator, MOD-2, MOD) f_i = (numerator * inv_denominator) % MOD product_f = (product_f * f_i) % MOD result = (product_f * x_fact_p) % MOD print(result)