#include <bits/stdc++.h>
using namespace std;
int modExp(int a, int n, int p) {
  int ret = 1;
  for (; n; n >>= 1, a = a * 1LL * a % p)
    if (n & 1) ret = ret * 1LL * a % p;
  return ret;
}
int g[255555];
int dp[18][255555];
int c[27][27];
int s[255555];
int main() {
  int n, k, p;
  cin >> n >> k >> p;
  if (n & 1) return printf("%d\n", modExp(k, n, p)), 0;
  g[0] = 1;
  for (int i = 1; i <= n; i++) g[i] = g[i - 1] * 1LL * modExp(i, p - 2, p) % p;
  for (int i = 0; i <= k; i++) {
    c[i][0] = c[i][i] = 1;
    for (int j = 1; j < i; j++) c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % p;
  }
  dp[0][0] = 1;
  for (int i = 0; i <= n; i++) {
    if ((n & i) != i) continue;
    int sn = 0;
    for (int j = i | (i + 1); j <= n; j = i | (j + 1)) {
      if ((n & j) == j) s[sn++] = j;
      if (j == n) break;
    }
    for (int j = 0; j < 18; j++)
      if (dp[j][i]) {
        for (int k = 0; k < sn; k++) {
          dp[j + 1][s[k]] =
              (dp[j + 1][s[k]] + (long long)dp[j][i] * g[s[k] - i]) % p;
        }
      }
  }
  int ans = 0;
  for (int i = 0; i <= k && i <= __builtin_popcount(n); i++)
    ans = (ans + c[k][i] * 1LL * dp[i][n]) % p;
  for (int i = 1; i <= n; i++) ans = ans * 1LL * i % p;
  cout << (modExp(k, n, p) + p - ans) % p << endl;
  return 0;
}
