#include <bits/stdc++.h>
using namespace std;
int n, m, p, tle, bct[600002], f[600002], finv[600002], inv[600002],
    c[20][600002];
long long a[20][600002], b[20][600002];
inline void fwt(long long x[], int len, int mde) {
  for (register int i = 2; i <= len; i <<= 1)
    for (register int j = 0, stp = i >> 1; j < len; j += i)
      for (register int k = j; k < j + stp; k++)
        (x[k + stp] += x[k] * mde) %= p;
}
int main() {
  scanf("%d%d%d", &n, &m, &p);
  int ans = 1;
  for (int i = 1; i <= n; i++) ans = 1ll * ans * m % p;
  if (n & 1) {
    printf("%d\n", ans);
    return 0;
  }
  n >>= 1;
  f[0] = finv[0] = f[1] = finv[1] = inv[1] = 1;
  for (int i = 2; i <= 600000; i++) {
    inv[i] = 1ll * (p - p / i) * inv[p % i] % p;
    f[i] = 1ll * f[i - 1] * i % p;
    finv[i] = 1ll * finv[i - 1] * inv[i] % p;
  }
  tle = 1;
  while (tle <= (n)) tle <<= 1;
  for (int i = 1; i < tle; i++) bct[i] = bct[i >> 1] + (i & 1);
  for (int i = 0; i < tle; i++) a[bct[i]][i] = finv[i * 2];
  b[0][0] = 1;
  int tn = bct[tle - 1];
  fwt(b[0], tle, 1);
  for (int i = 0; i <= tn; i++) fwt(a[i], tle, 1);
  while (m) {
    if (m & 1) {
      for (register int i = tn; ~i; i--) {
        for (int j = 0; j < i; j++)
          for (register int ii = 0; ii < tle; ii += 2) {
            (b[i][ii] += b[j][ii] * a[i - j][ii]) %= p;
            (b[i][ii + 1] += b[j][ii + 1] * a[i - j][ii + 1]) %= p;
          }
      }
    }
    for (int i = tn; ~i; i--) {
      for (register int j = 0; j < i; j++)
        for (register int ii = 0; ii < tle; ii += 2) {
          a[i][ii] = (a[i][ii] + a[j][ii] * a[i - j][ii]) % p;
          a[i][ii + 1] = (a[i][ii + 1] + a[j][ii + 1] * a[i - j][ii + 1]) % p;
        }
    }
    m >>= 1;
  }
  fwt(b[bct[n]], tle, p - 1);
  printf("%d\n", (ans - 1ll * b[bct[n]][n] * f[n * 2] % p + p) % p);
}
