#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
using ll = long long;
using ld = long double;
ll MOD;
const ll root = 3;
ll binpow(ll a, ll b) {
  ll res = 1;
  while (b) {
    if (b & 1) res = (res * a) % MOD;
    a = (a * a) % MOD;
    b >>= 1;
  }
  return res;
}
ll modInv(ll a) { return binpow(a, MOD - 2); }
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
const int mxN = 1 << 18;
int n, k;
ll dp[mxN][27];
ll F[mxN];
bool p[mxN];
int main() {
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  cin.tie(0)->sync_with_stdio(0);
  cin >> n >> k >> MOD;
  vector<ll> fact(n + 1);
  vector<ll> ifact(n + 1);
  fact[0] = 1;
  for (int i = (1); i < (n + 1); ++i) {
    fact[i] = (fact[i - 1] * i) % MOD;
  }
  ifact[n] = modInv(fact[n]);
  for (int i = (n)-1; i >= (0); --i) {
    ifact[i] = (ifact[i + 1] * (i + 1)) % MOD;
  }
  ll res = binpow(k, n);
  if (n & 1) {
    cout << res << "\n";
  } else {
    p[n] = 1;
    for (int i = (n + 1) - 1; i >= (1); --i)
      if (p[i]) {
        for (int msk = i - (i & (-i)), j = msk;; --j &= msk) {
          p[j] = 1;
          if (!j) break;
        }
      }
    dp[0][0] = 1;
    for (int i = (1); i < (n + 1); ++i)
      if (p[i]) {
        for (int msk = i - (i & (-i)), j = msk;; --j &= msk) {
          for (int cnt = (0); cnt < (min(k, __builtin_popcount(j) + 1));
               ++cnt) {
            dp[i][cnt + 1] = (dp[i][cnt + 1] + dp[j][cnt] * ifact[i - j]) % MOD;
          }
          if (!j) break;
        }
      }
    for (int i = (1); i < (k + 1); ++i) {
      ll sub = dp[n][i] * fact[n] % MOD;
      sub = sub * fact[k] % MOD;
      sub = sub * ifact[k - i] % MOD;
      res = (res + MOD - sub) % MOD;
    }
    cout << res << "\n";
  }
  return 0;
}
