#include <bits/stdc++.h>
using namespace std;
const int N = 250005;
int n, k, P, ans, f[30][N], fac[N], ifac[N], inv[N];
inline int ksm(register int x, register int L) {
  register int ans = 1;
  while (L)
    L& 1 ? ans = (0ll + ans) * x % P, 0 : 0, x = (0ll + x) * x % P, L >>= 1;
  return ans;
}
inline int dfs(const int x, const int s) {
  if (x > k) return 0;
  if (~f[x][s]) return f[x][s];
  if (!s) return f[x][s] = (0ll + fac[n]) * fac[k] % P * ifac[k - x] % P;
  f[x][s] = 0;
  const int ss = s - (s & -s);
  for (register int i = ss; i; i = (i - 1) & ss)
    f[x][s] = (f[x][s] + (0ll + dfs(x + 1, i)) * ifac[s - i]) % P;
  f[x][s] = (f[x][s] + (0ll + dfs(x + 1, 0)) * ifac[s]) % P;
  return f[x][s];
}
int main() {
  scanf("%d%d%d", &n, &k, &P), ans = ksm(k, n);
  if (n & 1) return printf("%d", ans), 0;
  for (register int i =
           (fac[0] = fac[1] = ifac[0] = ifac[1] = inv[0] = inv[1] = 1) + 1;
       i <= n; ++i)
    fac[i] = (0ll + fac[i - 1]) * i % P,
    inv[i] = (0ll + inv[P % i]) * (P - P / i) % P,
    ifac[i] = (0ll + ifac[i - 1]) * inv[i] % P;
  memset(f, -1, sizeof(f)), ans -= dfs(0, n),
      printf("%d", ans < 0 ? ans + P : ans);
  return 0;
}
