#include <bits/stdc++.h>
using namespace std;
const int N = 300010;
int n, K, mod;
int dp[N][20];
int cnt[N], mx[N];
int cj[N], inv[N];
int power(int x, int y) {
  int ret = 1;
  for (; y; y >>= 1, x = 1ll * x * x % mod) {
    if (y & 1) ret = 1ll * ret * x % mod;
  }
  return ret;
}
int C(int i, int j) { return 1ll * cj[i] * inv[j] % mod * inv[i - j] % mod; }
int main() {
  scanf("%d%d%d", &n, &K, &mod);
  int i, j, k;
  int ans = 0;
  int down, up, tmp, now, cur1, cur2;
  if (n & 1) {
    printf("%d\n", power(K, n));
    return 0;
  }
  cj[0] = 1;
  for (i = 1; i <= n; i++) cj[i] = 1ll * cj[i - 1] * i % mod;
  inv[n] = power(cj[n], mod - 2);
  inv[0] = 1;
  for (i = n - 1; i; i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % mod;
  for (i = 1; i <= n; i++)
    for (j = 0; j <= 18; j++)
      if (1 << j & i) cnt[i]++;
  for (i = 1; i <= n; i++)
    for (j = 18; j >= 0; j--)
      if (1 << j & i) {
        mx[i] = 1 << j;
        break;
      }
  dp[0][0] = 1;
  for (i = 1; i <= n; i++) {
    if ((n & i) != i) continue;
    now = i ^ mx[i];
    for (k = now; k >= 0; k = (k - 1) & now) {
      cur1 = k + mx[i];
      cur2 = i ^ cur1;
      up = min(K - 1, cnt[cur2]);
      tmp = C(i, cur1);
      for (j = 0; j <= up; j++) {
        dp[i][j + 1] = (dp[i][j + 1] + 1ll * dp[cur2][j] * tmp) % mod;
      }
      if (k == 0) break;
    }
  }
  for (j = 1; j <= min(cnt[n], K); j++)
    ans = (ans + 1ll * dp[n][j] * C(K, j) % mod * cj[j]) % mod;
  ans = (power(K, n) - ans + mod) % mod;
  printf("%d\n", ans);
  return 0;
}
