#include <bits/stdc++.h>
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m, MOD;
  while (cin >> n >> m >> MOD) {
    vector<long long int> inv(m + 1);
    inv[1] = 1;
    for (int n = 2; n <= m; n++) {
      inv[n] = (MOD - MOD / n) * inv[MOD % n] % MOD;
      assert(inv[n] * n % MOD == 1);
    }
    auto add = [&](long long int &x, long long int y) {
      x += y;
      if (x >= MOD) x -= MOD;
    };
    vector<long long int> ways(m + 1), sum(m + 1), sum_n(m + 1);
    for (int n = 1; n <= m; n++) sum_n[n] = n + sum_n[n - 1];
    ways[0] = 1;
    for (int n = 1; n <= m; n++) {
      long long int coef = 1;
      for (int pos = 0; pos < n; pos++) {
        int a = pos, b = n - 1 - pos;
        long long int to_ways = ways[a] * ways[b] % MOD;
        add(ways[n], (n + 1) * coef % MOD * to_ways % MOD);
        long long int to_sum = 0;
        add(to_sum, sum[a] * ways[b] % MOD);
        add(to_sum, sum[b] * ways[a] % MOD);
        add(sum[n], (n + 1) * coef % MOD * to_sum % MOD);
        add(sum[n], to_ways * coef % MOD * (sum_n[a] + sum_n[b]) % MOD);
        coef = coef * (n - 1 - pos) % MOD * inv[pos + 1] % MOD;
      }
    }
    vector<vector<long long int> > ways2(n + 1, vector<long long int>(m + 1)),
        sum2(n + 1, vector<long long int>(m + 1));
    ways2[0][0] = 1;
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j <= min(i, m); j++) {
        ways2[i][j] = ways2[i - 1][j];
        sum2[i][j] = sum2[i - 1][j];
        long long int coef = j;
        for (int k = 1; k <= j; k++) {
          int ni = max(0, i - k - 1);
          int nj = j - k;
          long long int to_ways = ways2[ni][nj] * coef % MOD;
          long long int to_sum = sum2[ni][nj] * coef % MOD;
          add(ways2[i][j], ways[k] * to_ways % MOD);
          add(sum2[i][j], sum[k] * to_ways % MOD);
          add(sum2[i][j], ways[k] * to_sum % MOD);
          coef = coef * (j - k) % MOD * inv[k + 1] % MOD;
        }
      }
    }
    cout << sum2[n][m] << endl;
  }
  return 0;
}
