#include <bits/stdc++.h>
using namespace std;
const int N = (1 << 18), M = 20;
int n, k, p, l, vt, q[N], ifac[N], f[M][N], g[M][N], h[M][N];
inline long long pows(long long u, int v) {
  long long ans = 1;
  while (v > 0) {
    if (v & 1) ans = ans * u % p;
    u = u * u % p, v = v >> 1;
  }
  return ans;
}
inline void fwt(int *s) {
  for (int d = 1; d < l; d = d << 1)
    for (int i = 0, r = d << 1; i < l; i += r)
      for (int j = 0; j < d; j++) s[i + j + d] = (s[i + j] + s[i + j + d]) % p;
}
inline void twf(int *s) {
  for (int d = 1; d < l; d = d << 1)
    for (int i = 0, r = d << 1; i < l; i += r)
      for (int j = 0; j < d; j++)
        s[i + j + d] = (s[i + j + d] - s[i + j] + p) % p;
}
inline void mulfg() {
  memset(h, 0, sizeof(h));
  for (int i = 0; i <= vt; i++)
    for (int j = 0; j <= vt; j++) {
      if (i + j > vt) break;
      for (int k = 0; k < l; k++)
        h[i + j][k] = (h[i + j][k] + 1ll * f[i][k] * g[j][k]) % p;
    }
  for (int i = 0; i <= vt; i++) twf(h[i]);
  for (int i = 0; i <= vt; i++)
    for (int x = 0; x < l; x++)
      if (q[x] != i) h[i][x] = 0;
  for (int i = 0; i <= vt; i++) fwt(h[i]);
  for (int i = 0; i <= vt; i++)
    for (int k = 0; k < l; k++) g[i][k] = h[i][k];
}
inline void mulff() {
  memset(h, 0, sizeof(h));
  for (int i = 0; i <= vt; i++)
    for (int j = 0; j <= vt; j++) {
      if (i + j > vt) break;
      for (int k = 0; k < l; k++)
        h[i + j][k] = (h[i + j][k] + 1ll * f[i][k] * f[j][k]) % p;
    }
  for (int i = 0; i <= vt; i++) twf(h[i]);
  for (int i = 0; i <= vt; i++)
    for (int x = 0; x < l; x++)
      if (q[x] != i) h[i][x] = 0;
  for (int i = 0; i <= vt; i++) fwt(h[i]);
  for (int i = 0; i <= vt; i++)
    for (int k = 0; k < l; k++) f[i][k] = h[i][k];
}
int main() {
  cin >> n >> k >> p, l = (1 << 18);
  bool fl = 0;
  long long c = pows(k, n);
  if (n & 1) {
    cout << c << endl;
    return 0;
  }
  ifac[0] = 1;
  for (int i = 1; i < l; i++) ifac[i] = ifac[i - 1] * pows(i, p - 2) % p;
  for (int i = 0; i < l; i++) q[i] = __builtin_popcount(i);
  vt = q[n];
  for (int i = 0; i < l; i++) f[q[i]][i] = ifac[i];
  for (int i = 0; i <= 18; i++) fwt(f[i]);
  while (k > 0) {
    if (k & 1) {
      if (!fl) {
        for (int i = 0; i <= vt; i++)
          for (int x = 0; x < l; x++) g[i][x] = f[i][x];
        fl = 1;
      } else
        mulfg();
    }
    k = k >> 1;
    if (!k) break;
    mulff();
  }
  twf(g[q[n]]);
  cout << (c - g[q[n]][n] * pows(ifac[n], p - 2) % p + p) % p << endl;
}
