import std.algorithm, std.array, std.container, std.range, std.bitmanip; import std.numeric, std.math, std.bigint, std.random, core.bitop; import std.string, std.regex, std.conv, std.stdio, std.typecons; const int mod = 10 ^^ 9 + 7; void main() { auto n = readln.chomp.to!int; auto p = pascalTriangle!int(n, mod); auto memo = new int[][](n + 1, n + 1); foreach (i; 0..n+1) memo[i][] = -1; foreach (i; 0..n+1) memo[0][i] = memo[i][0] = 0; memo[0][0] = 1; int calc(int x, int y) { if (memo[x][y] >= 0) { return memo[x][y]; } else { auto r1 = modMul(calc(x - 1, y), y, mod); auto r2 = (calc(x - 1, y - 1) + r1) % mod; return memo[x][y] = r2; } } auto r = 0; foreach (i; 1..n+1) { foreach (j; i..n+1) { auto s1 = p[n][j]; auto s2 = calc(j, i); auto s3 = modMul(s1, s2, mod); auto s4 = modPow(i * (i - 1), n - j, mod); r = (r + modMul(s3, s4, mod)) % mod; } } writeln(r); } int modMul(int a, int b, int mod) { return ((a.to!long * b.to!long) % mod).to!int; } T modPow(T)(T a, T b, T mod) { if (b == 0) return 1; if (a == 0) return 0; T c = 1; for (; b > 0; a = modMul(a, a, mod), b >>= 1) if ((b & 1) == 1) c = modMul(c, a, mod); return c; } T[][] pascalTriangle(T)(size_t n, T mod = 0) { auto t = new T[][](n + 1); t[0] = new T[](1); t[0][0] = 1; foreach (i; 1..n+1) { t[i] = new T[](i + 1); t[i][0] = t[i][$-1] = 1; foreach (j; 1..i) { t[i][j] = t[i - 1][j - 1] + t[i - 1][j]; if (mod != 0) t[i][j] %= mod; } } return t; }