#include <bits/stdc++.h>
using namespace std;
int n, k, md;
inline void add(int &x, int y) {
  x += y;
  if (x >= md) x -= md;
}
int val[1 << 20], cnt;
int dp[1 << 20][20];
int fac[300010], inv[300010];
int ans;
int qmul(int x, int p) {
  int res = 1;
  for (; p; p >>= 1, x = 1LL * x * x % md)
    if (p & 1) res = 1LL * res * x % md;
  return res;
}
int main() {
  scanf("%d%d%d", &n, &k, &md);
  if (n & 1) {
    printf("%d", qmul(k, n));
    return 0;
  }
  fac[0] = 1;
  for (int i = 1; i <= n; i++) fac[i] = 1LL * fac[i - 1] * i % md;
  inv[n] = qmul(fac[n], md - 2);
  for (int i = n - 1; i >= 0; i--) inv[i] = 1LL * inv[i + 1] * (i + 1) % md;
  for (int i = 0; i < 20; i++)
    if (n >> i & 1) val[1 << (cnt++)] = (1 << i);
  for (int i = 1; i < (1 << cnt); i++) val[i] = val[i - (i & -i)] + val[i & -i];
  dp[0][0] = fac[n];
  for (int i = 0; i < cnt; i++) {
    int st = ((1 << cnt) - 1) ^ ((1 << i) - 1);
    for (int j = (st - 1) & st;; j = (j - 1) & st) {
      if (!dp[j | ((1 << i) - 1)][i]) continue;
      int t = ((1 << cnt) - 1) ^ j ^ ((1 << i) - 1);
      int nst = t ^ (t & -t);
      for (int nj = nst;; nj = (nj - 1) & nst) {
        add(dp[j | ((1 << i) - 1) | nj | (t & -t)][i + 1],
            1LL * dp[j | ((1 << i) - 1)][i] * inv[val[nj | (t & -t)]] % md);
        if (!nj) break;
      }
      if (!j) break;
    }
  }
  int A = 1;
  for (int i = 1; i <= cnt && i <= k; i++) {
    A = 1LL * A * (k + 1 - i) % md;
    add(ans, 1LL * A * dp[(1 << cnt) - 1][i] % md);
  }
  printf("%d", (qmul(k, n) + md - ans) % md);
  return 0;
}
