#include <bits/stdc++.h>
using namespace std;
namespace io {
const int L = (1 << 19) + 1;
char ibuf[L], *iS, *iT, obuf[L], *oS = obuf, *oT = obuf + L - 1, c, st[55];
int f, tp;
char gc() {
  if (iS == iT) {
    iT = (iS = ibuf) + fread(ibuf, 1, L, stdin);
    return iS == iT ? EOF : *iS++;
  }
  return *iS++;
}
template <class I>
void gi(I& x) {
  for (f = 1, c = gc(); c < '0' || c > '9'; c = gc())
    if (c == '-') f = -1;
  for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15);
  x *= f;
}
};  // namespace io
using io::gc;
using io::gi;
int n, k, p, l, b[250010];
unsigned long long x[26][250010], f[250010], g[250010], a, d;
unsigned long long pw(unsigned long long x, int y = p - 2) {
  unsigned long long a = 1;
  while (y) {
    if (y & 1) a = a * x % p;
    x = x * x % p;
    y >>= 1;
  }
  return a;
}
unsigned long long dfs(int k, int n) {
  if (b[n] < k) return 0;
  if (k == 1) return x[k][n] = g[n];
  if (x[k][n]) return x[k][n];
  int t = 0;
  for (int i = n & (n - 1); i; i = n & (i - 1))
    if (b[i] >= k - 1) {
      x[k][n] += dfs(k - 1, i) * g[n ^ i];
      if (++t == 18) t = 0, x[k][n] %= p;
    }
  x[k][n] %= p;
  return x[k][n];
}
unsigned long long c(int n, int m) { return f[n] * g[m] % p * g[n - m] % p; }
int main() {
  gi(n);
  gi(k);
  gi(p);
  for (register int i = 1; i <= n; i++) b[i] = b[i >> 1] + (i & 1);
  a = pw(k, n);
  if (n & 1) {
    printf("%d\n", a);
    return 0;
  }
  l = min(k, b[n]);
  f[0] = 1;
  for (register int i = 1; i <= n; i++) f[i] = f[i - 1] * i % p;
  g[n] = pw(f[n]);
  for (register int i = n; i >= 1; i--) g[i - 1] = g[i] * i % p;
  for (register int i = l; i >= 1; i--) d += c(k, i) * dfs(i, n);
  a = (a - d % p * f[n] % p + p) % p;
  printf("%lld\n", a);
  return 0;
}
