#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long x = 0, y = 1;
  char ch = ' ';
  for (; (ch != '-' && (ch > '9' || ch < '0')); ch = getchar())
    ;
  if (ch == '-') y = -1, ch = getchar();
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - 48;
  return x * y;
}
const long long N = 3e5 + 10, M = 19;
long long jc[N], ny[N], num[N], inv[M + 10];
long long n, k, m, mod;
inline long long add(long long x, long long y) {
  return x + y >= mod ? x + y - mod : x + y;
}
inline long long sub(long long x, long long y) {
  return x >= y ? x - y : x - y + mod;
}
inline long long ksm(long long x, long long y) {
  long long mul = 1;
  while (y) {
    if (y & 1) mul = mul * x % mod;
    y >>= 1;
    x = x * x % mod;
  }
  return mul;
}
inline void prep(long long n) {
  jc[0] = 1;
  for (register long long i = 1; i <= n; ++i) jc[i] = jc[i - 1] * i % mod;
  ny[n] = ksm(jc[n], mod - 2);
  for (register long long i = n - 1; i >= 0; --i)
    ny[i] = ny[i + 1] * (i + 1) % mod;
  for (register long long i = 1; i <= n; ++i) num[i] = num[i - (i & (-i))] + 1;
  for (register long long i = 1; i <= 22; ++i) inv[i] = ksm(i, mod - 2);
}
inline void fwt(long long f[], long long op) {
  for (register long long o = 2, k = 1; o <= (1 << m); o <<= 1, k <<= 1)
    for (register long long i = 0; i < (1 << m); i += o)
      for (register long long j = 0; j < k; ++j)
        f[i + j + k] = (f[i + j + k] + f[i + j] * op + mod) % mod;
}
inline void Getln(long long f[], long long g[]) {
  g[0] = 0;
  for (register long long i = 1; i <= m; ++i) {
    g[i] = i * f[i] % mod;
    for (register long long j = 1; j < i; ++j)
      g[i] = (g[i] - f[i - j] * g[j] % mod * j % mod + mod) % mod;
    g[i] = g[i] * inv[i] % mod;
  }
}
inline void Getexp(long long g[], long long f[]) {
  f[0] = 1;
  for (register long long i = 1; i <= m; ++i) {
    f[i] = 0;
    for (register long long j = 1; j <= i; ++j)
      f[i] = (f[i] + f[i - j] * g[j] % mod * j) % mod;
    f[i] = f[i] * inv[i] % mod;
  }
}
long long A[M], B[M];
inline void Mul(long long f[]) {
  Getln(f, A);
  for (register long long i = 0; i <= m; ++i) A[i] = A[i] * k % mod;
  Getexp(A, f);
}
long long f[M][N], g[M][N], h[M];
signed main() {
  long long x, y, z;
  n = read();
  k = read();
  mod = read();
  long long len = 1;
  if (n & 1) {
    printf("%lld\n", ksm(k, n));
    return 0;
  }
  for (; len <= n; len <<= 1, ++m)
    ;
  prep(n);
  for (register long long i = 0; i <= n; ++i) f[num[i]][i] = ny[i];
  for (register long long i = 0; i <= m; ++i) fwt(f[i], 1);
  for (register long long i = 0; i < (1 << m); ++i) {
    for (register long long j = 0; j <= m; ++j) h[j] = f[j][i];
    Mul(h);
    for (register long long j = 0; j <= m; ++j) f[j][i] = h[j];
  }
  fwt(f[num[n]], -1);
  long long ans = ksm(k, n);
  ans = sub(ans, f[num[n]][n] * jc[n] % mod);
  printf("%lld\n", ans);
  return 0;
}
