/** author: shobonvip created: 2024.11.29 22:55:48 **/ #include using namespace std; //* ATCODER #include using namespace atcoder; typedef dynamic_modint<0> mint; //*/ /* BOOST MULTIPRECISION #include using namespace boost::multiprecision; //*/ typedef long long ll; #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--) #define all(v) v.begin(), v.end() template bool chmin(T &a, const T &b) { if (a <= b) return false; a = b; return true; } template bool chmax(T &a, const T &b) { if (a >= b) return false; a = b; return true; } template T max(vector &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]); return ret; } template T min(vector &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]); return ret; } template T sum(vector &a){ T ret = 0; for (int i=0; i<(int)a.size(); i++) ret += a[i]; return ret; } mint Garner(vector m,vector r){ int n = m.size(); vector t(n); for(int i=0; i vector convolution_mint(vector a,vector b){ static constexpr unsigned long long M0 = 998244353; static constexpr unsigned long long M1 = 754974721; static constexpr unsigned long long M2 = 469762049; vector aa(a.size()),bb(b.size()); for(int i=0; i(aa,bb); auto c1 = convolution(aa,bb); auto c2 = convolution(aa,bb); vector ret(c0.size()); vector m = {M0,M1,M2}; for(int i=0; i r = {c0[i],c1[i],c2[i]}; vector t(3); for(int j=0; j<3; j++){ long long cur = 0LL; long long cm = 1LL; for(int k=0; k std::vector poly_prod(std::vector> f) { if ((int)f.size() == 0) return {1}; std::deque> p; for (int i=0; i<(int)f.size(); i++){ p.push_back(f[i]); } while((int)p.size() > 1) { std::vector p1 = p.back(); p.pop_back(); std::vector p2 = p.back(); p.pop_back(); p.push_front(convolution_mint(p1, p2)); } return p.back(); } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); ll n, m, p; cin >> n >> m >> p; mint::set_mod(p); vector fact(n+1), factinv(n+1); fact[0] = 1; rep(i,1,n+1) fact[i] = fact[i-1] * i; factinv[n] = fact[n].inv(); rrep(i,0,n) factinv[i] = factinv[i+1] * (i + 1); vector> ft; rep(i,0,n) ft.push_back({1, i+1}); vector f = poly_prod(ft); mint ans = 0; rep(k,1,m+1){ ans += fact[m]*factinv[k]*factinv[m-k]*factinv[k]*f[k]*fact[k]*fact[n-k]*factinv[n]; //cout << ans.val() << endl; } cout << ans.val() << endl; }