#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1 << 18;
long long n, m, k, Mod, ans, f[19][maxn], fac[maxn], inv[maxn], cnt[maxn];
vector<long long> h;
inline long long power(long long a, long long b) {
  long long r = 1;
  while (b) {
    if (b & 1) r = r * a % Mod;
    a = a * a % Mod;
    b >>= 1;
  }
  return r;
}
inline long long C(long long n, long long m) {
  return n < m ? 0 : (fac[n] * inv[m] % Mod) * inv[n - m] % Mod;
}
inline void FWT(long long *f, long long op) {
  for (long long Mid = 1; Mid < m; Mid <<= 1)
    for (long long i = 0; i < m; i += (Mid << 1))
      for (long long j = 0; j < Mid; ++j) f[i + j + Mid] += op * f[i + j];
  for (long long i = (0), _end_ = (m - 1); i <= _end_; ++i) f[i] %= Mod;
}
inline vector<long long> operator*(vector<long long> a, vector<long long> b) {
  vector<long long> c;
  c.resize(19);
  for (long long i = (0), _end_ = (18); i <= _end_; ++i)
    for (long long j = (0), _end_ = (18 - i); j <= _end_; ++j)
      c[i + j] += a[i] * b[j];
  for (long long i = (0), _end_ = (18); i <= _end_; ++i) c[i] %= Mod;
  return c;
}
inline vector<long long> power(vector<long long> a, long long b) {
  vector<long long> r = a;
  --b;
  while (b) {
    if (b & 1) r = r * a;
    a = a * a;
    b >>= 1;
  }
  return r;
}
signed main() {
  scanf("%lld%lld%lld", &n, &k, &Mod);
  m = 1 << 18;
  fac[0] = inv[0] = 1;
  for (long long i = (1), _end_ = (m - 1); i <= _end_; ++i)
    fac[i] = fac[i - 1] * i % Mod;
  inv[m - 1] = power(fac[m - 1], Mod - 2);
  for (long long i = m - 2; i >= 1; --i) inv[i] = inv[i + 1] * (i + 1) % Mod;
  ans = power(k, n);
  if (n % 2 == 0) {
    for (long long i = (0), _end_ = (m - 1); i <= _end_; ++i) {
      for (long long j = (0), _end_ = (17); j <= _end_; ++j)
        if ((i >> j) & 1) ++cnt[i];
      f[cnt[i]][i] = inv[i];
    }
    for (long long i = (0), _end_ = (18); i <= _end_; ++i) FWT(f[i], 1);
    for (long long i = (0), _end_ = (m - 1); i <= _end_; ++i) {
      h.resize(19);
      for (long long j = (0), _end_ = (18); j <= _end_; ++j) h[j] = f[j][i];
      h = power(h, k);
      for (long long j = (0), _end_ = (18); j <= _end_; ++j) f[j][i] = h[j];
    }
    FWT(f[cnt[n]], -1);
    ans = (ans - fac[n] * f[cnt[n]][n]) % Mod;
  }
  printf("%lld\n", (ans + Mod) % Mod);
  return 0;
}
