#include <bits/stdc++.h>
using namespace std;
const int maxn = 2.5e5 + 10;
template <typename T>
inline T read() {
  T ans = 0, flag = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') flag = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    ans = ans * 10 + (c - 48);
    c = getchar();
  }
  return ans * flag;
}
int n, k, p;
long long power_pow(long long base, int b, const long long MOD = p) {
  long long ans = 1;
  while (b) {
    if (b & 1) (ans *= base) %= MOD;
    (base *= base) %= MOD;
    b >>= 1;
  }
  return ans;
}
int fac[maxn], Inv[maxn];
void init() {
  const int MOD = p;
  fac[0] = 1;
  for (register int i(1), end_i(n); i <= end_i; i++)
    fac[i] = 1ll * i * fac[i - 1] % MOD;
  Inv[n] = power_pow(fac[n], MOD - 2);
  for (register int i(n - 1), end_i(0); i >= end_i; i--)
    Inv[i] = (i + 1ll) * Inv[i + 1] % MOD;
}
int f[26][maxn];
int dp(int x, int S) {
  if (~f[x][S]) return f[x][S];
  const int MOD = p;
  if (!S) {
    long long res = fac[n];
    for (register int i(1), end_i(x); i <= end_i; i++)
      res = res * (k - i + 1) % MOD;
    return res;
  }
  long long res = 0;
  int U = S & (S - 1);
  for (int U = S & (S - 1), T = U;; T = (T - 1) & U) {
    res = (res + 1ll * Inv[S - T] * dp(x + 1, T)) % MOD;
    if (!T) break;
  }
  return f[x][S] = res;
}
int main() {
  cin >> n >> k >> p;
  long long ans = power_pow(k, n);
  const int MOD = p;
  if (n % 2 == 0) {
    init();
    memset(f, -1, sizeof f);
    ans = (ans + MOD - dp(0, n)) % MOD;
  }
  cout << ans << endl;
  return 0;
}
