#include <bits/stdc++.h>
using namespace std;
int n, k, mo, N, m, fac[1 << 18], ifac[1 << 18], siz[1 << 18];
int qpow(int a, int b) {
  int x = a;
  a = 1;
  while (b) {
    if (b & 1) a = 1LL * a * x % mo;
    x = 1LL * x * x % mo, b >>= 1;
  }
  return a;
}
struct Array {
  int a[18];
  int& operator[](int x) { return a[x]; }
  Array operator+=(Array y) {
    for (int i = 0; i < m; i++) a[i] = (a[i] + y[i]) % mo;
    return *this;
  }
  Array operator-=(Array y) {
    for (int i = 0; i < m; i++) a[i] = (a[i] + mo - y[i]) % mo;
    return *this;
  }
  Array operator*=(Array y) {
    for (int i = m - 1, _; i >= 0; i--)
      if (a[i]) {
        _ = a[i], a[i] = 0;
        for (int j = m - 1 - i; j >= 0; j--)
          a[i + j] = (a[i + j] + 1LL * _ * y[j]) % mo;
      }
    return *this;
  }
} f[1 << 18];
void qpow(Array& a, int b) {
  Array x = a;
  for (int i = 0; i < m; i++) a[i] = (i == 0);
  while (b) {
    if (b & 1) a *= x;
    b >>= 1;
    if (!b) return;
    x *= x;
  }
}
void work() {
  scanf("%d %d %d", &n, &k, &mo);
  if (n & 1) printf("%d", qpow(k, n)), exit(0);
  for (N = 1, m = 0; N <= n; N <<= 1, m++)
    ;
  fac[0] = 1, ifac[0] = 1, siz[0] = 0;
  for (int i = 1; i < N; i++)
    fac[i] = 1LL * fac[i - 1] * i % mo, ifac[i] = qpow(fac[i], mo - 2),
    siz[i] = siz[i / 2] + (i & 1);
  for (int i = 0; i < N; i++) f[i][siz[i]] = ifac[i];
  for (int i = 1; i < N; i <<= 1)
    for (int j = 0; j < N; j++)
      if (j & i) f[j] += f[j - i];
  for (int i = 0; i < N; i++) qpow(f[i], k);
  for (int i = 1; i < N; i <<= 1)
    for (int j = 0; j < N; j++)
      if (j & i) f[j] -= f[j - i];
  printf("%d", int(qpow(k, n) + mo - 1LL * f[n][siz[n]] * fac[n] % mo) % mo);
}
int main() {
  work();
  return 0;
}
