#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 18 | 1;
int n, m, M, fac[N], inv[N], num[19][N], a[19], b[19], Inv;
unsigned long long c[19];
int ksm(int x, int y) {
  int ans = 1;
  for (; y; y >>= 1, x = (long long)x * x % M)
    if (y & 1) ans = (long long)ans * x % M;
  return ans;
}
void fwt(int y[], int len, int opt) {
  for (int i = 2; i <= len; i <<= 1)
    for (int j = 0; j < len; j += i)
      for (int k = j; k < j + i / 2; k++) {
        int u = y[k], v = y[k + i / 2];
        y[k] = (u + v) % M;
        y[k + i / 2] = (u + M - v) % M;
        if (opt == -1)
          y[k] = (long long)y[k] * Inv % M,
          y[k + i / 2] = (long long)y[k + i / 2] * Inv % M;
      }
}
int main() {
  scanf("%d%d%d", &n, &m, &M);
  if (n & 1) {
    printf("%d\n", ksm(m, n));
    return 0;
  }
  Inv = ksm(2, M - 2);
  fac[0] = inv[0] = 1;
  for (int i = 1; i <= n; i++)
    fac[i] = (long long)fac[i - 1] * i % M, inv[i] = ksm(fac[i], M - 2);
  int len = (int)log2(n) + 1;
  for (int i = 0; i <= n; i++) num[__builtin_popcount(i)][i] = inv[i];
  for (int i = 0; i <= len; i++) fwt(num[i], 1 << len, 1);
  for (int i = 0; i < 1 << len; i++) {
    for (int j = 0; j <= len; j++) a[j] = num[j][i];
    memset(b, 0, sizeof b);
    b[0] = 1;
    for (int T = m; T; T >>= 1) {
      if (T & 1) {
        for (int j = 0; j <= len; j++)
          for (int k = 0; k <= len - j; k++)
            c[j + k] = (c[j + k] + (unsigned long long)a[j] * b[k]);
        for (int j = 0; j <= len; j++) b[j] = c[j] % M, c[j] = 0;
      }
      for (int j = 0; j <= len; j++)
        for (int k = 0; k <= len - j; k++)
          c[j + k] = (c[j + k] + (unsigned long long)a[j] * a[k]);
      for (int j = 0; j <= len; j++) a[j] = c[j] % M, c[j] = 0;
    }
    for (int j = 0; j <= len; j++) num[j][i] = b[j];
  }
  for (int i = 0; i <= len; i++) fwt(num[i], 1 << len, -1);
  int ans = (ksm(m, n) - (long long)num[__builtin_popcount(n)][n] * fac[n]) % M;
  printf("%d\n", (ans + M) % M);
}
