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;
using ll = long long;
using ld = long double;
const ld eps = 1e-8;
template <class U, class V>
ostream& operator<<(ostream& out, const pair<U, V>& u) {
  return out << "(" << u.first << ", " << u.second << ")";
}
template <class Con, class = decltype(begin(declval<Con>()))>
typename enable_if<!is_same<Con, string>::value, ostream&>::type operator<<(
    ostream& out, const Con& con) {
  out << "{";
  for (auto beg = con.begin(), it = beg; it != con.end(); ++it)
    out << (it == beg ? "" : ", ") << *it;
  return out << "}";
}
template <size_t i, class T>
ostream& print_tuple_utils(ostream& out, const T& tup) {
  if constexpr (i == tuple_size<T>::value)
    return out << ")";
  else
    return print_tuple_utils<i + 1, T>(out << (i ? ", " : "(") << get<i>(tup),
                                       tup);
}
template <class... U>
ostream& operator<<(ostream& out, const tuple<U...>& u) {
  return print_tuple_utils<0, tuple<U...>>(out, u);
}
int mod;
struct modint {
  int x;
  modint(int xx = 0) : x(xx) {}
  modint(ll xx) : x((int)(xx % mod)) {}
  friend inline modint operator+(modint u, const modint& v) { return u += v; }
  modint& operator+=(const modint& o) {
    if ((x += o.x) >= mod) x -= mod;
    return *this;
  }
  friend inline modint operator-(modint u, const modint& v) { return u -= v; }
  modint& operator-=(const modint& o) {
    if ((x -= o.x) < 0) x += mod;
    return *this;
  }
  friend inline modint operator*(modint u, const modint& v) { return u *= v; }
  modint& operator*=(const modint& o) { return *this = modint(1ll * x * o.x); }
  modint pow(ll exp, modint ans = 1) const {
    modint base = *this;
    for (; exp > 0; exp >>= 1, base *= base)
      if (exp & 1) ans *= base;
    return ans;
  }
  friend inline modint operator/(modint u, const modint& v) { return u /= v; }
  modint& operator/=(const modint& o) { return *this = o.pow(mod - 2, *this); }
  friend ostream& operator<<(ostream& out, const modint& u) {
    return out << u.x;
  }
};
using mint = modint;
const int maxn = 1024;
const int maxd = 16;
mint dp[maxn][maxd][maxn];
mint ifac[maxd];
void precal() {
  ifac[0] = 1;
  for (int i = (int)(1); i < (int)(maxd); ++i) ifac[i] = ifac[i - 1] / i;
}
int n, d;
int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin >> n >> d >> mod;
  precal();
  if (n == 1) {
    cout << "1";
    return 0;
  }
  dp[1][0][0] = 1;
  dp[1][d - 1][0] = 1;
  for (int treesize = (int)(2); treesize < (int)(n + 1); ++treesize) {
    ;
    if (0)
      cerr << "["
              "treesize"
              " = "
           << (treesize) << "] " << endl;
    for (int root_deg = (int)(0); root_deg < (int)(d + 1); ++root_deg) {
      for (int max_sub_size = (int)(1); max_sub_size < (int)(treesize);
           ++max_sub_size) {
        ;
        if (0)
          cerr << "["
                  "root_deg"
                  " = "
               << (root_deg) << "] "
               << "["
                  "max_sub_size"
                  " = "
               << (max_sub_size) << "] " << endl;
        auto& cur = dp[treesize][root_deg][max_sub_size];
        cur += dp[treesize][root_deg][max_sub_size - 1];
        auto u =
            max_sub_size > 1 ? dp[max_sub_size][d - 1][max_sub_size - 1] : 1;
        if (0)
          cerr << "["
                  "u"
                  " = "
               << (u) << "] " << endl;
        mint cur_mul = 1;
        for (int cur_sub = (int)(1); cur_sub < (int)(root_deg + 1); ++cur_sub) {
          cur_mul *= (u + cur_sub - 1);
          int new_size = treesize - cur_sub * max_sub_size;
          if (new_size <= 0) break;
          if (0)
            cerr << "["
                    "new_size"
                    " = "
                 << (new_size) << "] "
                 << "["
                    "root_deg - cur_sub"
                    " = "
                 << (root_deg - cur_sub) << "] " << endl;
          auto comb = cur_mul * ifac[cur_sub];
          auto rest =
              dp[new_size][root_deg - cur_sub][min(new_size, max_sub_size) - 1];
          if (0)
            cerr << "["
                    "cur_sub"
                    " = "
                 << (cur_sub) << "] "
                 << "["
                    "comb.x"
                    " = "
                 << (comb.x) << "] "
                 << "["
                    "rest"
                    " = "
                 << (rest) << "] " << endl;
          cur += rest * comb;
        }
        if (0)
          cerr << "["
                  "cur"
                  " = "
               << (cur) << "] " << endl;
      }
    }
  }
  auto ans = dp[n][d][(n - 1) / 2];
  if (n % 2 == 0) {
    auto t = dp[n / 2][d - 1][n / 2 - 1];
    ans += t * (t + 1) * ifac[2];
  }
  cout << ans.x;
  return 0;
}