class mint: def __init__(self, x): self.__x = x % md def __str__(self): return str(self.__x) def __add__(self, other): if isinstance(other, mint): other = other.__x return mint(self.__x + other) def __sub__(self, other): if isinstance(other, mint): other = other.__x return mint(self.__x - other) def __rsub__(self, other): return mint(other - self.__x) def __mul__(self, other): if isinstance(other, mint): other = other.__x return mint(self.__x * other) __radd__ = __add__ __rmul__ = __mul__ def __truediv__(self, other): if isinstance(other, mint): other = other.__x return mint(self.__x * pow(other, md - 2, md)) def __pow__(self, power, modulo=None): return mint(pow(self.__x, power, md)) def nCr(com_n, com_r): if com_n < com_r: return 0 return fac[com_n] / fac[com_r] / fac[com_n - com_r] memo = {} def s(n, r): if n < r: return 0 if n == r or r == 1: return mint(1) if (n, r) in memo: return memo[n, r] memo[n, r] = res = s(n - 1, r - 1) + r * s(n - 1, r) return res # combinationの準備 md = 10 ** 9 + 7 n_max = 555 fac = [mint(1)] for i in range(1, n_max + 1): fac.append(fac[-1] * i) def main(): n = int(input()) # 1グループになるのは1通りと分かるので2グループ以上に分かれる場合を考える ans = mint(1) # 夫婦が同じ車に乗るa組と別の車に乗るb組を決める for a in range(2, n + 1): b = n - a # n組からa組選ぶのがnCa通り c = nCr(n, a) # a,bを固定したら、gグループ作るときの場合の数を求める for g in range(2, a + 1): # a組の夫婦をgグループに分ける方法がs(a,g)通り # bの1組の夫婦の別れ方がg*(g-1)通り if b: ans += c * s(a, g) * pow(g * (g - 1), b, md) else: ans += c * s(a, g) print(ans) main()