#include <bits/stdc++.h>
using namespace std;
const int N = 250010;
unsigned long long P, fa[N], inv[N], k, ans, ans1, f[18][N];
unsigned long long sqr(unsigned long long x) { return x * x % P; }
int n;
unsigned long long poww(unsigned long long a, unsigned long long n) {
  if (n == 0) return 1;
  if (n % 2 == 0) return sqr(poww(a, n / 2));
  return sqr(poww(a, n / 2)) * a % P;
}
unsigned long long C(int a, int b) {
  if (b > a) return 0;
  return fa[a] * inv[b] % P * inv[a - b] % P;
}
int min(int a, int b) { return a < b ? a : b; }
inline void calc() {
  int l, i, j;
  for (l = 2; l <= min(17, k); l++) {
    for (i = n; i >= (1 << l) - 1; i = (i - 1) & n) {
      for (j = i; j >= (1 << (l - 1)) - 1; j = (j - 1) & i) {
        if (i == j) continue;
        f[l][i] += f[l - 1][j] * inv[i ^ j];
        if (f[l][i] > 17446744073709551616ull) {
          f[l][i] %= P;
        }
      }
      f[l][i] %= P;
    }
    ans1 = (ans1 + f[l][n] * C(k, l)) % P;
  }
}
int main() {
  int i, j, l;
  scanf("%d%lld%lld", &n, &k, &P);
  ans = 1;
  for (i = 1; i <= n; i++) ans = ans * k % P;
  if (n % 2 == 1) {
    printf("%llu\n", ans);
    return 0;
  }
  fa[0] = 1;
  for (i = 1; i <= n; i++) fa[i] = fa[i - 1] * i % P;
  inv[0] = 1;
  for (i = 1; i <= n; i++) inv[i] = poww(fa[i], P - 2);
  memset(f, 0, sizeof(f));
  for (i = 1; i <= n; i++) f[1][i] = inv[i];
  ans1 = f[1][n] * k % P;
  calc();
  ans1 = ans1 * fa[n] % P;
  printf("%llu\n", (ans - ans1 + P) % P);
}
