MOD = 10 ** 9 + 7 N, M = map(int, input().split()) dp = [[0] * (N - M + 1) for _ in range(3)] dp[0][0] = 1 for i in range(M + 1): dp[(i + 1) % 3] = [0] * (N - M + 1) for j in range(N - M + 1): if i > 0: dp[i % 3][j] += dp[(i - 1) % 3][j] * (M - i + 1) if j > 0: dp[i % 3][j] += dp[i % 3][j - 1] * i dp[i % 3][j] %= MOD print(dp[M % 3][N - M])