#include <bits/stdc++.h>
using namespace std;
const int N = 262144;
int L, n, k, Mo, len, bit[20], fac[N], inv[N], cnt[N], g[20][N], f[20][N],
    h[20], p[20];
int pwr(int x, int y) {
  int z = 1;
  for (; y; y >>= 1, x = (long long)x * x % Mo)
    if (y & 1) z = (long long)z * x % Mo;
  return z;
}
void inc(int &x, int y) { x = x + y >= Mo ? x + y - Mo : x + y; }
void dec(int &x, int y) { x = x - y < 0 ? x - y + Mo : x - y; }
void FWT(int *a, int len) {
  for (int i = 1; i < len; i <<= 1)
    for (int j = 0; j < len; j += i << 1)
      for (int k = 0; k < i; k++) inc(a[j + k + i], a[j + k]);
}
void IFWT(int *a, int len) {
  for (int i = 1; i < len; i <<= 1)
    for (int j = 0; j < len; j += i << 1)
      for (int k = 0; k < i; k++) dec(a[j + k + i], a[j + k]);
}
void get_ln(int *a, int *b, int n) {
  b[0] = 0;
  for (int i = 1; i <= n; i++) {
    b[i] = (long long)a[i] * i % Mo;
    for (int j = 1; j <= i - 1; j++)
      (b[i] += Mo - (long long)b[j] * a[i - j] % Mo * j % Mo) %= Mo;
    b[i] = (long long)b[i] * pwr(i, Mo - 2) % Mo;
  }
}
void get_exp(int *a, int *b, int n) {
  b[0] = 1;
  for (int i = 1; i <= n; i++) {
    b[i] = 0;
    for (int j = 1; j <= i; j++)
      (b[i] += (long long)a[j] * b[i - j] % Mo * j % Mo) %= Mo;
    b[i] = (long long)b[i] * pwr(i, Mo - 2) % Mo;
  }
}
int main() {
  scanf("%d%d%d", &L, &k, &Mo);
  int all = pwr(k, L);
  if (L & 1) {
    printf("%d\n", all);
    return 0;
  }
  fac[0] = 1;
  for (int i = 1; i <= L; i++) fac[i] = (long long)fac[i - 1] * i % Mo;
  inv[L] = pwr(fac[L], Mo - 2);
  for (int i = L - 1; i >= 0; i--)
    inv[i] = (long long)inv[i + 1] * (i + 1) % Mo;
  for (int s = 1; s <= L; s++) cnt[s] = cnt[s ^ (s & -s)] + 1;
  for (int i = 0; i <= 18; i++)
    if (L >> i & 1) bit[++n] = 1 << i;
  len = 1 << n;
  for (int i = 0; i <= len - 1; i++) {
    int s = 0;
    for (int j = 1; j <= n; j++)
      if (i >> (j - 1) & 1) s += bit[j];
    g[cnt[i]][i] = inv[s];
  }
  for (int i = 0; i <= n; i++) FWT(g[i], len);
  for (int s = 0; s <= len - 1; s++) {
    for (int i = 0; i <= n; i++) h[i] = g[i][s];
    get_ln(h, p, n);
    for (int i = 0; i <= n; i++) p[i] = (long long)p[i] * k % Mo;
    get_exp(p, h, n);
    for (int i = 0; i <= n; i++) f[i][s] = h[i];
  }
  IFWT(f[n], len);
  int ans = (long long)f[n][len - 1] * fac[L] % Mo;
  ans = (all - ans + Mo) % Mo;
  printf("%d\n", ans);
  return 0;
}
