#include <bits/stdc++.h>
using namespace std;
int n, K, mod, inv2;
inline int add(int a, int b) {
  if ((a += b) >= mod) a -= mod;
  return a;
}
inline int dec(int a, int b) {
  if ((a -= b) < 0) a += mod;
  return a;
}
inline int mult(int a, int b) {
  long long t = 1ll * a * b;
  if (t >= mod) t %= mod;
  return t;
}
inline int power(int a, int b) {
  int out = 1;
  while (b) {
    if (b & 1) out = mult(out, a);
    a = mult(a, a);
    b >>= 1;
  }
  return out;
}
int tf[20];
inline void conv(int* A, int* B) {
  memset(tf, 0, sizeof(tf));
  for (int i = 0; i < 18; i++) {
    for (int j = 0; i + j < 18; j++) {
      tf[i + j] = add(tf[i + j], mult(A[i], B[j]));
    }
  }
  for (int i = 0; i < 18; i++) A[i] = tf[i];
}
int f2[20];
inline void pw(int* A, int k) {
  memset(f2, 0, sizeof(f2));
  f2[0] = 1;
  while (k) {
    if (k & 1) conv(f2, A);
    conv(A, A);
    k >>= 1;
  }
  for (int i = 0; i < 18; i++) A[i] = f2[i];
}
int f[262144][18], fac[262144], ifac[262144];
int main() {
  scanf("%d%d%d", &n, &K, &mod);
  if (n & 1) {
    printf("%d\n", power(K, n));
    return 0;
  }
  fac[0] = 1;
  for (int i = 1; i < 262144; i++) fac[i] = mult(fac[i - 1], i);
  ifac[262143] = power(fac[262143], mod - 2);
  for (int i = 262142; i >= 0; i--) ifac[i] = mult(ifac[i + 1], i + 1);
  inv2 = power(2, mod - 2);
  for (int i = 0; i < 262144; i++) f[i][__builtin_popcount(i)] = ifac[i];
  for (int i = 1; i < 262144; i <<= 1) {
    for (int j = 0; j < 262144; j += (i << 1)) {
      for (int k = 0; k < i; k++) {
        for (int l = 0; l < 18; l++)
          f[i + j + k][l] = add(f[i + j + k][l], f[j + k][l]);
      }
    }
  }
  for (int i = 0; i < 262144; i++) pw(f[i], K);
  for (int i = 1; i < 262144; i <<= 1) {
    for (int j = 0; j < 262144; j += (i << 1)) {
      for (int k = 0; k < i; k++) {
        for (int l = 0; l < 18; l++)
          f[i + j + k][l] = dec(f[i + j + k][l], f[j + k][l]);
      }
    }
  }
  printf("%d\n", dec(power(K, n), mult(f[n][__builtin_popcount(n)], fac[n])));
  return 0;
}
