#include <bits/stdc++.h>
#pragma GCC optimize("O3,no-stack-protector")
#pragma GCC target("tune=native")
#pragma GCC diagnostic ignored "-Wunused-result"
using namespace std;
template <class T>
void _R(T &x) {
  cin >> x;
}
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%" PRId64, &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template <class T, class... U>
void R(T &head, U &...tail) {
  _R(head);
  R(tail...);
}
template <class T>
void _W(const T &x) {
  cout << x;
}
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%" PRId64, x); }
void _W(const double &x) { printf("%.16f\n", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template <class T>
void _W(const vector<T> &x) {
  for (auto i = x.begin(); i != x.end(); _W(*i++))
    if (i != x.cbegin()) putchar(' ');
}
void W() {}
template <class T, class... U>
void W(const T &head, const U &...tail) {
  _W(head);
  putchar(sizeof...(tail) ? ' ' : '\n');
  W(tail...);
}
template <class T>
inline bool chkmax(T &a, const T &b) {
  return b > a ? a = b, true : false;
}
template <class T>
inline bool chkmin(T &a, const T &b) {
  return b < a ? a = b, true : false;
}
template <class T, class F = less<T>>
void sort_uniq(vector<T> &v, F f = F()) {
  sort(begin(v), end(v), f);
  v.resize(unique(begin(v), end(v)) - begin(v));
}
template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
int64_t inv(int64_t x, int64_t p) {
  int64_t a = x, b = p, u = 1, v = 0;
  while (b != 0) {
    auto t = a / b;
    a -= t * b;
    u -= t * v;
    swap(a, b);
    swap(u, v);
  }
  return u < 0 ? u + p : u;
}
inline int bit(int64_t x, int i) { return (x >> i) & 1; }
const int K = 26;
const int N = 250010;
int64_t p;
int rev[N], tbl[N], tbl2[N / 2];
int dp[2][N / 2];
int64_t n, k;
int main() {
  R(n, k, p);
  int64_t ans = 1;
  for (int i = 0; i < int(n); i++) ans = ans * k % p;
  if (n % 2 == 0) {
    int64_t up = 1;
    for (int i = (1); i <= int(n); i++) up = up * i % p;
    rev[0] = rev[1] = 1;
    for (int i = (2); i <= int(n); i++)
      rev[i] = (int64_t)rev[p % i] * (p - p / i) % p;
    tbl[0] = 1;
    for (int i = (1); i <= int(n); i++)
      tbl[i] = (int64_t)tbl[i - 1] * rev[i] % p;
    for (int i = (0); i <= int(n / 2); i++) tbl2[i] = tbl[i * 2];
    n /= 2;
    int u = 0;
    dp[u][0] = 1;
    for (int i = n; i; i = (i - 1) & n) dp[u][i] = tbl2[i];
    const int64_t G = LLONG_MAX - p * p;
    const int64_t pp = G / p * p;
    for (int ik = 0; ik < int(k - 1); ik++) {
      u ^= 1;
      memset(dp[u], 0, n * sizeof(int));
      dp[u][0] = 1;
      for (int i = 1; i <= n; i++)
        if ((n & i) == i) {
          int64_t s = dp[u ^ 1][i];
          for (int j = i; j; j = (j - 1) & i) {
            s += (int64_t)tbl2[j] * dp[u ^ 1][i ^ j];
            if (s > G) s %= p;
          }
          dp[u][i] = s % p;
        }
    }
    int64_t dn = dp[u][n];
    int64_t t = up * dn % p;
    ;
    ans = (ans - t % p + p) % p;
  }
  W(ans);
  return 0;
}
