#include <bits/stdc++.h>
template <class T>
void read(T &);
template <class T>
void write(const T &);
typedef const long long &cll;
typedef const int &ci;
const int iinf = 2147483647;
const long long llinf = 9223372036854775807ll;
using std::abs;
using std::max;
using std::min;
const int N = 18;
const int M = 1 << N;
int pow(int a, int b, int m);
void FWT(int *A, int lim, bool opt);
int f[N + 1][M + 5], g[N + 1][M + 5];
int fac[M + 5], ifac[M + 5];
int n, k, p;
int main() {
  read(n), read(k), read(p);
  if (n & 1) {
    write(pow(k, n, p)), putchar('\n');
  } else {
    int lim = M;
    fac[0] = 1;
    for (int i = 1; i <= lim; ++i) {
      fac[i] = fac[i - 1] * 1ll * i % p;
    }
    ifac[lim] = pow(fac[lim], p - 2, p);
    for (int i = lim - 1; i >= 0; --i) {
      ifac[i] = ifac[i + 1] * 1ll * (i + 1) % p;
    }
    for (int i = 0; i < lim; ++i) {
      f[__builtin_popcount(i)][i] = ifac[i];
      g[0][i] = 1;
    }
    for (int i = 0; i <= N; ++i) {
      FWT(f[i], lim, false);
    }
    int tmp = k;
    while (tmp) {
      if (tmp & 1) {
        for (int i = N; i >= 0; --i) {
          for (int j = 0; j < i; ++j) {
            for (int k = 0; k < lim; ++k) {
              g[i][k] = (g[i][k] + g[j][k] * 1ll * f[i - j][k]) % p;
            }
          }
        }
      }
      for (int i = N; i >= 0; --i) {
        for (int j = 0; j < i; ++j) {
          for (int k = 0; k < lim; ++k) {
            f[i][k] = (f[i][k] + f[j][k] * 1ll * f[i - j][k]) % p;
          }
        }
      }
      tmp >>= 1;
    }
    FWT(g[__builtin_popcount(n)], lim, true);
    write((pow(k, n, p) - g[__builtin_popcount(n)][n] * 1ll * fac[n] % p + p) %
          p),
        putchar('\n');
  }
  return 0;
}
template <class T>
inline void read(T &Re) {
  T k = 0;
  char ch = getchar();
  int flag = 1;
  while (!(ch >= '0' && ch <= '9')) {
    if (ch == '-') {
      flag = -1;
    }
    ch = getchar();
  }
  while ((ch >= '0' && ch <= '9')) {
    k = (k << 1) + (k << 3) + ch - '0';
    ch = getchar();
  }
  Re = flag * k;
}
template <class T>
inline void write(const T &Wr) {
  if (Wr < 0) {
    putchar('-');
    write(-Wr);
  } else {
    if (Wr < 10) {
      putchar(Wr + '0');
    } else {
      write(Wr / 10);
      putchar((Wr % 10) + '0');
    }
  }
}
void inc(int &a, int b) { (a += b) >= p ? a -= p : a; }
void dec(int &a, int b) { (a -= b) < 0 ? a += p : a; }
int pow(int a, int b, int m) {
  int ans = 1, now = a;
  while (b) {
    if (b & 1) {
      ans = ans * 1ll * now % m;
    }
    now = now * 1ll * now % m;
    b >>= 1;
  }
  return ans;
}
void FWT(int *A, int lim, bool opt) {
  for (int l = 1; l < lim; l <<= 1) {
    for (int i = 0; i < lim; i += (l << 1)) {
      for (int j = 0; j < l; ++j) {
        if (opt) {
          dec(A[i | j | l], A[i | j]);
        } else {
          inc(A[i | j | l], A[i | j]);
        }
      }
    }
  }
}
