Problem: A tree is a connected graph without cycles.

Two trees, consisting of n vertices each, are called isomorphic if there exists a permutation p: {1, ..., n} → {1, ..., n} such that the edge (u, v) is present in the first tree if and only if the edge (pu, pv) is present in the second tree.

Vertex of the tree is called internal if its degree is greater than or equal to two.

Count the number of different non-isomorphic trees, consisting of n vertices, such that the degree of each internal vertex is exactly d. Print the answer over the given prime modulo mod.

Input

The single line of the input contains three integers n, d and mod (1 ≤ n ≤ 1000, 2 ≤ d ≤ 10, 108 ≤ mod ≤ 109) — the number of vertices in the tree, the degree of internal vertices and the prime modulo.

Output

Print the number of trees over the modulo mod.

Examples

Input

5 2 433416647


Output

1


Input

10 3 409693891


Output

2


Input

65 4 177545087


Output

910726

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int N = 1000 + 10, D = 15;
int n, d, mod;
int dp[D][N][N];
int ifac[N];
void Add(int &x, int y) {
  if ((x += y) >= mod && (x -= mod))
    ;
}
int binom(int n, int m) {
  n %= mod;
  if (n < m) return 0;
  int pro = 1;
  for (int i = n; i >= n - m + 1; i--) pro = 1ll * pro * i % mod;
  pro = 1ll * pro * ifac[m] % mod;
  return pro;
}
int DP(int g, int n, int k) {
  if (dp[g][n][k] != -1) return dp[g][n][k];
  int &res = dp[g][n][k];
  if (n == 1) return res = 1;
  if (k == 0 || g == 0) return res = (n == 1 && g == 0);
  res = 0;
  Add(res, DP(g, n, k - 1));
  if ((k - 1) % (d - 1)) return res;
  int f = DP(d - 1, k, k - 1);
  for (int i = 1; i <= g; i++) {
    if (i * k >= n) break;
    Add(res, 1ll * DP(g - i, n - k * i, k - 1) * binom(f + i - 1, i) % mod);
  }
  return res;
}
void quit(int x) { printf("%d\n", x), exit(0); }
void initmath(int n) {
  ifac[0] = ifac[1] = 1;
  for (int i = 2; i <= n; i++)
    ifac[i] = 1ll * (mod - mod / i) * ifac[mod % i] % mod;
  for (int i = 1; i <= n; i++) ifac[i] = 1ll * ifac[i - 1] * ifac[i] % mod;
  return;
}
int calc(int g, int n, int k) {
  if (n == 1 || n == 2) return 1;
  if (n < g + 1) return 0;
  if ((n - g - 1) % (d - 1) != 0) return 0;
  return DP(g, n, k);
}
int main() {
  memset(dp, -1, sizeof(dp));
  scanf("%d%d%d", &n, &d, &mod);
  if (n == 1 || n == 2) quit(1);
  if (n < d + 1) quit(0);
  if ((n - d - 1) % (d - 1) != 0) quit(0);
  initmath(d);
  if (n & 1) quit(calc(d, n, n / 2));
  int ans = calc(d, n, n / 2);
  ans = (ans - binom(calc(d - 1, n / 2, n / 2 - 1), 2) + mod) % mod;
  quit(ans);
  return 0;
}