#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
long long n, k, p;
long long dp[30][300000];
long long f[300000], finv[300000];
inline long long qpow(long long a, long long b, long long p) {
  long long k = 1;
  while (b) {
    if (b & 1) k = k * a % p;
    a = a * a % p;
    b >>= 1;
  }
  return k;
}
long long num, is[30];
inline long long getdp(long long i, long long j) {
  if (i == 0 && j != 0) return 0;
  if (j == 0 && i != 0) return 0;
  if (dp[i][j] != -1) return dp[i][j];
  dp[i][j] = 0;
  long long inc = j & (-j), t = j;
  long long res = 0;
  t ^= inc;
  for (long long u = t;; u = (u - 1) & t) {
    res += getdp(i - 1, j - (u + inc)) * finv[(u + inc)] % p;
    if (u == 0) break;
  }
  res %= p;
  dp[i][j] = res;
  return dp[i][j];
}
signed main() {
  ios::sync_with_stdio(false);
  cin >> n >> k >> p;
  if (n % 2 == 1) cout << qpow(k, n, p), exit(0);
  f[0] = finv[0] = 1;
  for (long long i = 1; i <= 250000; i++) f[i] = f[i - 1] * i % p;
  finv[250000] = qpow(f[250000], p - 2, p);
  for (long long i = 250000 - 1; i >= 1; i--)
    finv[i] = finv[i + 1] * (i + 1) % p;
  memset(dp, -1, sizeof(dp));
  dp[0][0] = 1;
  long long ans = 0;
  for (long long i = 1; i <= k; i++) {
    ans += getdp(i, n) * f[n] % p * f[k] % p * finv[k - i] % p;
    ans %= p;
  }
  cout << (qpow(k, n, p) - ans + p) % p;
  cerr << endl << 1.0 * clock() / CLOCKS_PER_SEC;
}
