#include <bits/stdc++.h>
using namespace std;
int MOD;
int sum(int a, int b) { return a + b >= MOD ? a + b - MOD : a + b; }
int sub(int a, int b) { return a - b < 0 ? a - b + MOD : a - b; }
int mul(int a, int b) { return (1LL * a * b) % MOD; }
int pw(int a, int b) {
  if (!b) return 1;
  int r = pw(a, b / 2);
  r = mul(r, r);
  if (b % 2) r = mul(r, a);
  return r;
}
const int MAXZ = 18;
const int MAXN = 1 << MAXZ;
int fact[MAXN], ifact[MAXN];
int popCount[MAXN];
vector<int> polyConvolution(const vector<int> &v, int k) {
  if (k == 1) {
    return v;
  }
  if (k & 1) {
    vector<int> r = polyConvolution(v, k - 1);
    vector<int> s(r.size(), 0);
    for (int i = 0; i < v.size(); i++) {
      for (int j = 0; j <= i; j++) {
        s[i] = sum(s[i], mul(r[j], v[i - j]));
      }
    }
    return s;
  } else {
    vector<int> r = polyConvolution(v, k >> 1);
    vector<int> s(r.size(), 0);
    for (int i = 0; i < v.size(); i++) {
      for (int j = 0; j <= i; j++) {
        s[i] = sum(s[i], mul(r[j], r[i - j]));
      }
    }
    return s;
  }
}
vector<int> subset_pow_convolution(const vector<int> &a, int k) {
  assert(a.size() == MAXN);
  if (k == 1) return a;
  vector<vector<int>> fa(MAXZ + 1, vector<int>(MAXN)), fc = fa;
  for (int i = 0; i < MAXN; i++) {
    fa[popCount[i]][i] = a[i];
  }
  for (int sz = 0; sz <= MAXZ; sz++) {
    for (int i = 0; i < MAXZ; i++) {
      for (int msk = 0; msk < MAXN; msk++) {
        if (msk & (1 << i)) {
          fa[sz][msk] = sum(fa[sz][msk], fa[sz][msk ^ (1 << i)]);
        }
      }
    }
  }
  for (int msk = 0; msk < MAXN; msk++) {
    vector<int> tmp(MAXZ + 1);
    for (int sz = 0; sz <= MAXZ; sz++) tmp[sz] = fa[sz][msk];
    tmp = polyConvolution(tmp, k);
    for (int sz = 0; sz <= MAXZ; sz++) {
      fc[sz][msk] = tmp[sz];
    }
  }
  for (int sz = 0; sz <= MAXZ; sz++) {
    for (int i = 0; i < MAXZ; i++) {
      for (int msk = 0; msk < MAXN; msk++) {
        if (msk & (1 << i)) {
          fc[sz][msk] = sub(fc[sz][msk], fc[sz][msk ^ (1 << i)]);
        }
      }
    }
  }
  vector<int> soln(MAXN);
  for (int i = 0; i < MAXN; i++) soln[i] = fc[popCount[i]][i];
  return soln;
}
int main() {
  int n, k;
  cin >> n >> k >> MOD;
  fact[0] = 1;
  for (int i = 1; i < MAXN; i++) fact[i] = mul(i, fact[i - 1]);
  ifact[MAXN - 1] = pw(fact[MAXN - 1], MOD - 2);
  for (int i = MAXN - 2; i >= 0; i--) ifact[i] = mul(i + 1, ifact[i + 1]);
  for (int i = 1; i < MAXN; i++) {
    popCount[i] = popCount[i >> 1] + (i & 1);
  }
  int ans = pw(k, n);
  if (n % 2 == 0) {
    vector<int> ways(MAXN, 0);
    for (int i = 0; i < MAXN; i++) {
      if ((n & i) == i) {
        ways[i] = ifact[i];
      }
    }
    vector<int> dp = subset_pow_convolution(ways, k);
    ans = sub(ans, mul(dp[n], fact[n]));
  }
  cout << ans << endl;
  return 0;
}
