#include <bits/stdc++.h>
namespace Main {
namespace Source {
static inline const unsigned int qpow(unsigned int b, unsigned int e,
                                      const unsigned int mod) {
  unsigned int r(1);
  while (e) {
    if (e bitand 1) r = 1ull * r * b % mod;
    b = 1ull * b * b % mod, e >>= 1;
  }
  return r;
}
static inline const unsigned int finv(const unsigned int x,
                                      const unsigned int p) {
  return qpow(x, p - 2, p);
}
static unsigned int *invf, *fact;
struct __FILE {
  __FILE() {}
  compl __FILE() {
    if (invf) delete[] invf;
    if (fact) delete[] fact;
  }
} ____FILE;
static inline const void init(const unsigned int n, const unsigned int p) {
  if (not n) return;
  if (invf) delete[] invf;
  if (fact) delete[] fact;
  invf = new unsigned int[n], fact = new unsigned int[n], invf[0] = 1,
  fact[0] = 1;
  for (register unsigned int i(1); i < n; ++i)
    fact[i] = 1ull * fact[i - 1] * i % p;
  invf[n - 1] = finv(fact[n - 1], p);
  for (register unsigned int i(n - 2); i < n; --i)
    invf[i] = 1ull * invf[i + 1] * (i + 1) % p;
}
static inline const unsigned int lowbit(const unsigned int x) {
  return x bitand ~x + 1;
}
}  // namespace Source
using namespace Source;
enum { N = 250000, K = 26 };
static unsigned int n, p;
static short unsigned int k;
static unsigned int _f[N + 1][K + 1];
static const unsigned int f(const unsigned int a, const short unsigned int b) {
  static bool g(false);
  if (not g) {
    for (register unsigned int i(0); i <= n; ++i)
      for (register unsigned int j(0); j <= k; ++j) _f[i][j] = p;
    for (short unsigned int i(0); i <= k; ++i) {
      _f[0][i] = fact[n];
      for (short unsigned int j(0); j < k - i; ++j)
        _f[0][i] = 1ull * _f[0][i] * (k - j) % p;
    }
    g = true;
  }
  if (_f[a][b] < p) return _f[a][b];
  if (a and !b) return 0;
  const unsigned int t(a xor lowbit(a));
  _f[a][b] = 1ull * f(0, b - 1) * invf[a] % p;
  for (register unsigned int i(t); i; i = i - 1 & t)
    _f[a][b] = (_f[a][b] + 1ull * f(i, b - 1) * invf[a ^ i] % p) % p;
  return _f[a][b];
}
static inline const void main() {
  scanf("%u%hu%u", &n, &k, &p);
  if (n % 2) return (const void)printf("%u\n", qpow(k, n, p));
  init(n + 1, p);
  printf("%u\n", (qpow(k, n, p) + p - f(n, k)) % p);
}
}  // namespace Main
signed int main() {
  Main::main();
  return 0;
}
