#include using namespace std; int main(){ int N, M, P; cin >> N >> M >> P; vector dp(N + 1, 0); dp[0] = 1; vector dps(M + 1, 0); for (int i = 0; i < M; i++){ vector dp2(N + 1, 0); long long s = 0; for (int j = 1; j <= N; j++){ s += dp[j - 1]; s %= P; dp2[j] = s * j % P; dps[i + 1] += dp2[j]; dps[i + 1] %= P; } dp = dp2; } vector inv(N + 1); inv[1] = 1; for (int i = 2; i <= N; i++){ inv[i] = P - inv[P % i] * (P / i) % P; } vector fact(N + 1); vector finv(N + 1); fact[0] = 1; finv[0] = 1; for (int i = 1; i <= N; i++){ fact[i] = fact[i - 1] * i % P; finv[i] = finv[i - 1] * inv[i] % P; } auto binom = [&](int n, int k){ return fact[n] * finv[k] % P * finv[n - k] % P; }; long long S = 0; for (int i = 1; i <= M; i++){ S += dps[i] * binom(M, i) % P * fact[N - i] % P * finv[N - M] % P; S %= P; } S *= fact[N - M] * finv[N] % P; S %= P; cout << S << endl; }