local n, mod = io.read("*n", "*n") local mfl = math.floor local function bmulslow(x, y) local x1, y1 = x % 10000, y % 10000 local x2, y2 = mfl(x / 10000) % 10000, mfl(y / 10000) % 10000 local x3, y3 = mfl(x / 100000000), mfl(y / 100000000) local ret = (x1 * y1 + (x1 * y2 + x2 * y1) * 10000) % mod ret = (ret + (x1 * y3 + x2 * y2 + x3 * y1) * 10000 % mod * 10000 % mod) % mod ret = (ret + (x2 * y3 + x3 * y2) * 10000 % mod * 10000 % mod * 10000) % mod ret = (ret + x3 * y3 * 10000 % mod * 10000 % mod * 10000 % mod * 10000) % mod return ret end local bmul = bmulslow local function badd(x, y) return (x + y) % mod end local function bsub(x, y) return x < y and x - y + mod or x - y end local function modpow(src, pow) local res = 1 while 0 < pow do if pow % 2 == 1 then res = bmul(res, src) pow = pow - 1 end src = bmul(src, src) pow = mfl(pow / 2) end return res end local function modinv(src) return modpow(src, mod - 2) end local fact = {1} local invs = {1} local invfact = {1} for i = 2, n do fact[i] = bmul(fact[i - 1], i) invs[i] = bmul(mfl(mod / i), mod - invs[mod % i]) invfact[i] = bmul(invfact[i - 1], invs[i]) end local function getComb(n, k) if k == 0 or k == n then return 1 end return bmul(fact[n], bmul(invfact[k], invfact[n - k])) end local tree = {1, 1} for i = 3, n do tree[i] = modpow(i, i - 2) end local t = {{1}} -- i: dst node count for i = 2, n do t[i] = {} -- j: dst edge count - 1 for j = 1, i do -- k: src node count local v = 0 for k = 1, i - 1 do local sz = i - k if 0 < j - sz + 1 and j - sz + 1 <= k then v = badd(v, bmul(t[k][j - sz + 1] , bmul(getComb(n - k - 1, sz - 1), tree[sz]))) end end t[i][j] = v t[i][i] = bmul(getComb(n - 1, i - 1), tree[i]) end end for i = 1, n do print(t[n][i]) end