#include <bits/stdc++.h>
using namespace std;
long long dp[1000][1000], ckn[1000][1000], num[1000][1000];
signed main() {
  long long n, k, mod, all[1000], cost[1000];
  scanf("%lld %lld %lld", &n, &k, &mod);
  for (long long i = 0; i <= 700; i++) ckn[0][i] = 1;
  for (long long i = 1; i <= 700; i++) all[i] = 0, cost[i] = 0;
  all[0] = 1;
  cost[0] = 0;
  for (long long i = 1; i <= 700; i++)
    for (long long j = 1; j <= i; j++) {
      ckn[j][i] = (ckn[j][i - 1] + ckn[j - 1][i - 1]) % mod;
      long long t = ((2 * j * j - 2 * j + i * i + i - 2 * i * j) / 2) % mod,
                m = (all[j - 1] * all[i - j]) % mod;
      all[i] = (all[i] + (ckn[j - 1][i - 1] * m) % mod * (i + 1)) % mod;
      cost[i] = (cost[i] + ckn[j - 1][i - 1] *
                               (cost[j - 1] * (i + 1) % mod * all[i - j] % mod +
                                all[j - 1] * (i + 1) % mod * cost[i - j] % mod +
                                m * t % mod)) %
                mod;
    }
  for (long long i = 0; i <= n; i++) {
    num[i][i] = all[i];
    dp[i][i] = cost[i];
    num[i][0] = 1;
    for (long long j = 1; j <= min(i - 1, k); j++) {
      long long ans1 = 0, ans2 = 0;
      for (long long t = 1; t <= j + 1; t++) {
        ans1 = (ans1 + ckn[t - 1][j] * all[t - 1] % mod *
                           num[i - t][j - t + 1] % mod) %
               mod;
        ans2 = (ans2 + ckn[t - 1][j] *
                           (all[t - 1] * dp[i - t][j - t + 1] % mod +
                            num[i - t][j - t + 1] * cost[t - 1] % mod) %
                           mod) %
               mod;
      }
      num[i][j] = ans1;
      dp[i][j] = ans2;
    }
  }
  printf("%lld", dp[n][k]);
}
